Part Number Hot Search : 
15KPJ45A C2020D 44103 ESD5B5V RB2415 CSM3392 AN1446 1N6290
Product Description
Full Text Search
 

To Download SN8F2280 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 1 version 1.1 SN8F2280 series user?s manual sn8f2288 s s o o n n i i x x 8 8 - - b b i i t t m m i i c c r r o o - - c c o o n n t t r r o o l l l l e e r r sonix reserves the right to make change without further notice to any products herein to improve reliability, function or desig n. sonix does not assume any liability arising out of the application or use of an y product or circuit described her ein; neither does it convey a ny license under its patent rights nor the rights of others. sonix products are not designed, intended, or authorized for us as components in systems inten ded, for surgical implant into the body, or other applications intended to suppor t or sustain life, or for any other application in which the fai lure of the sonix product could create a situation where personal injury or death may occu r. should buyer purchase or use sonix products for any such uni ntended or unauthorized application. buyer shall indemnify and hold sonix and its officers, employees, subsidiaries, affiliates and distributors harmless against all claims, cost, damages, and expenses, and re asonable attorney fees arising out of, dire ctly or indirectly, any claim of pers onal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 2 version 1.1 amendment history version date description ver 1.0 2009/03/06 1. first version is released. ver 1.1 2009/08/11 1. remove adc external high reference voltage source from p40. 2. modify wakeup time?s description. 3. modify uart baud rate pr e-scalar?s description. 4. modify sio?s transfer rate select bit.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 3 version 1.1 table of content amendment history .......................................................................................................................... 2 1 product overview ......................................................................................................................... 9 1.1 features ............................................................................................................................... ............... 9 1.2 system block diagram .............................................................................................................. 10 1.3 pin assignment ............................................................................................................................... 11 1.4 pin descriptions ............................................................................................................................. 12 1.5 pin circuit diagrams ................................................................................................................... 14 2 central processor unit (cpu) .............................................................................................. 15 2.1 memory map ............................................................................................................................... ...... 15 2.1.1 program memory (rom) ........................................................................................................ 15 2.1.1.1 reset vector (0000h) ...................................................................................................... 16 2.1.1.2 interrupt vector (0008h) ............................................................................................. 17 2.1.1.3 look-up table description ........................................................................................ 19 2.1.1.4 jump table description ............................................................................................... 21 2.1.1.5 checksum calculation .............................................................................................. 23 2.1.2 code option table .................................................................................................................. 24 2.1.3 data memory (ram) .................................................................................................................. 25 2.1.4 system register........................................................................................................................ 27 2.1.4.1 system register table ................................................................................................ 27 2.1.4.2 system register description ................................................................................... 27 2.1.4.3 bit definition of system register ........................................................................... 28 2.1.4.4 accumulator ................................................................................................................... 31 2.1.4.5 program flag ................................................................................................................... 32 2.1.4.6 program counter .......................................................................................................... 33 2.1.4.7 y, z registers .................................................................................................................... 36 2.1.4.8 r registers ......................................................................................................................... 37 2.2 addressing mode .......................................................................................................................... 38 2.2.1 immediate addressing mode .............................................................................................. 38 2.2.2 directly addressing mode ................................................................................................. 38 2.2.3 indirectly addressing mode ............................................................................................. 38 2.3 stack operation ............................................................................................................................ 39 2.3.1 overview ............................................................................................................................... ...... 39 2.3.2 stack registers ........................................................................................................................ 40 2.3.3 stack operation example .................................................................................................... 41 3 reset ............................................................................................................................... ...................... 42
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 4 version 1.1 3.1 overview ............................................................................................................................... ............ 42 3.2 power on reset ............................................................................................................................... 44 3.3 watchdog reset ............................................................................................................................ 44 3.4 brown out reset ........................................................................................................................... 45 3.4.1 brown out description ........................................................................................................ 45 3.4.2 the system operating voltage decsription ............................................................... 46 3.4.3 brown out reset improvement ......................................................................................... 47 3.5 external reset .............................................................................................................................. 48 3.6 external reset circuit ............................................................................................................. 48 3.6.1 simply rc reset circuit .................................................................................................................. 48 3.6.2 diode & rc reset circuit ............................................................................................................... 49 3.6.3 zener diode reset circuit ............................................................................................................... 49 3.6.4 voltage bias reset circuit ............................................................................................................... 50 3.6.5 external reset ic ............................................................................................................................. 50 4 system clock ............................................................................................................................... ... 51 4.1 overview ............................................................................................................................... ............ 51 4.2 clock block diagram ................................................................................................................. 51 4.3 oscm register ............................................................................................................................... .. 52 4.4 system high clock ....................................................................................................................... 53 4.4.1 external high clock ............................................................................................................. 53 4.4.1.1 crystal/ceramic ............................................................................................................. 54 4.1.1.2 external clock signal ............................................................................................... 55 4.2 system low clock ........................................................................................................................ 56 4.2.1 system clock measurement ............................................................................................... 57 5 system operation mode ........................................................................................................... 58 5.1 overview ............................................................................................................................... ............ 58 5.2 system mode switching example ......................................................................................... 59 5.3 wakeup ............................................................................................................................... ................ 61 5.3.1 overview ............................................................................................................................... ...... 61 5.3.2 wakeup time............................................................................................................................... 61 6 interrupt ............................................................................................................................... ............ 62 6.1 overview ............................................................................................................................... ............ 62 6.2 inten interrupt enable register ......................................................................................... 63 6.3 intrq interrupt request register ....................................................................................... 65 6.4 gie global interrupt operation .......................................................................................... 66 6.5 push, pop routine ........................................................................................................................... 66 6.6 int0 (p0.0) & int1 (p0.1) interrupt operation ....................................................................... 68 6.7 t0 interrupt operation .............................................................................................................. 70
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 5 version 1.1 6.8 t1 interrupt operation .............................................................................................................. 71 6.9 tc0 interrupt operation ........................................................................................................... 72 6.10 tc1 interrupt operation ......................................................................................................... 73 6.11 tc2 interrupt operation ......................................................................................................... 74 6.12 usb interrupt operation ........................................................................................................ 75 6.13 wakeup interrupt operation ............................................................................................... 76 6.14 sio interrupt operation .......................................................................................................... 77 6.15 multi-interrupt operation ................................................................................................... 78 7 i/o port ............................................................................................................................... ................. 79 7.1 i/o port mode ............................................................................................................................... .... 79 7.2 i/o pull up register ...................................................................................................................... 81 7.3 i/o open-drain register .............................................................................................................. 82 7.4 i/o port data register ................................................................................................................ 83 7.5 i/o port1 wakeup control register ..................................................................................... 84 8 timers ............................................................................................................................... ................... 85 8.1 watchdog timer ............................................................................................................................ 85 8.2 timer 0 (t0) ............................................................................................................................... .......... 87 8.2.1 overview ............................................................................................................................... ...... 87 8.2.2 t0m mode register.................................................................................................................. 87 8.2.3 t0c counting register .......................................................................................................... 88 8.2.4 t0 timer operation sequence ............................................................................................ 89 8.3 timer t1 (t1) ............................................................................................................................... ........ 90 8.3.1 overview ............................................................................................................................... ...... 90 8.3.2 t1m mode register.................................................................................................................. 90 8.3.3 t1c counting register .......................................................................................................... 91 8.3.4 t1 timer operation sequence ............................................................................................ 91 8.4 timer/counter 0 (tc0~tc2) ......................................................................................................... 93 8.4.1 overview ............................................................................................................................... ...... 93 8.4.2 tcnm mode register ............................................................................................................... 94 8.4.3 tcnc counting register ....................................................................................................... 96 8.4.4 tcnr auto-load register ..................................................................................................... 97 8.4.5 tcn clock frequency output (buzzer) ......................................................................... 98 8.4.6 tcn timer operation sequence ......................................................................................... 99 8.5 pwm n mode ............................................................................................................................... ....... 100 8.5.1 overview ............................................................................................................................... .... 100 8.5.2 tcnirq and pwm duty ................................................................................................................ 101 8.5.3 pwm duty with tcnr changing .................................................................................................. 102 8.5.4 pwm program example ....................................................................................................... 103
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 6 version 1.1 9 universal serial bus (usb) .................................................................................................... 104 9.1 overview ............................................................................................................................... .......... 104 9.2 usb machine ............................................................................................................................... .... 104 9.3 usb interrupt ............................................................................................................................... . 105 9.4 usb enumeration ........................................................................................................................ 105 9.5 usb registers ............................................................................................................................... . 106 9.5.1 usb device address register ........................................................................................... 106 9.5.2 usb status register .............................................................................................................. 106 9.5.3 usb data count register ................................................................................................... 107 9.5.4 usb enable control register .......................................................................................... 107 9.5.5 usb endpoint?s ack handshaking flag register ..................................................................... 108 9.5.6 usb endpoint?s nak handshaking flag register ..................................................................... 108 9.5.7 usb endpoint 0 enable register ..................................................................................... 109 9.5.8 usb endpoint 1 enable register ..................................................................................... 109 9.5.9 usb endpoint 2 enable register ..................................................................................... 110 9.5.10 usb endpoint 3 enable register ................................................................................... 111 9.5.11 usb endpoint 4 enable register ................................................................................... 112 9.5.12 usb endpoint fifo ad dress setting register ......................................................... 112 9.5.13 usb data pointer register .............................................................................................. 113 9.5.14 usb data read/write register ....................................................................................... 113 9.5.15 upid register ........................................................................................................................ 113 9.5.16 endpoint toggle bit control register .................................................................... 114 10 universal asynchronous receiver/transmitter (uart) .............................. 115 10.1 overview ............................................................................................................................... ........ 115 10.2 uart operation .......................................................................................................................... 115 10.3 uart transmitter control register ............................................................................. 118 10.4 uart receiver control register ...................................................................................... 119 10.5 uart baud rate control register ................................................................................... 120 10.6 uart data buffer ...................................................................................................................... 121 11 serial input/output transceiver ................................................................................ 122 11.1 overview ............................................................................................................................... ........ 122 11.2 siom mode register .................................................................................................................. 125 11.3 siob data buffer ....................................................................................................................... 126 11.4 sior register description ..................................................................................................... 126 12 8 channel analog to digital converter ............................................................... 128 12.1 overview ............................................................................................................................... ........ 128 12.2 adm register ............................................................................................................................... 129
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 7 version 1.1 12.3 adr registers .............................................................................................................................. 129 12.4 adb registers .............................................................................................................................. 130 12.5 p4con registers .......................................................................................................................... 131 12.6 adc converting time ............................................................................................................... 131 12.7 adc contorl notice ................................................................................................................. 132 12.7.1 adc signal ............................................................................................................................... 132 12.7.2 adc program ......................................................................................................................... 132 12.8 adc circuit ............................................................................................................................... .... 133 13 main series port (msp) .......................................................................................................... 134 13.1 overview ............................................................................................................................... ........ 134 13.2 msp status register ................................................................................................................. 134 13.3 msp mode register 1 ................................................................................................................. 135 13.4 msp mode register 2 ................................................................................................................. 136 13.4 msp buffer register ................................................................................................................. 137 13.5 msp address register ............................................................................................................. 137 13.6 s lave m ode o peration .................................................................................................................... 138 13.6.1 addressing ............................................................................................................................... .... 138 13.6.2 slave receiving ............................................................................................................................ 138 13.6.3 slave transmission ...................................................................................................................... 139 13.6.4 general call address .................................................................................................................. 140 13.6.5 slave wake up .............................................................................................................................. 140 13.7 m aster m ode o peration ................................................................................................................. 142 13.7.1 master mode support .................................................................................................................. 142 13.7.2 msp rate generator (mrg) ....................................................................................................... 142 13.7.3 msp master mode start condition .......................................................................................... 143 13.7.4 msp master mode repeat start condition .............................................................................. 143 13.7.5 acknowledge sequence timing ................................................................................................... 144 13.7.6 msp master mode stop condition timing ............................................................................... 144 13.7.6 clock arbitration ......................................................................................................................... 145 13.7.6 master mode transmission ......................................................................................................... 146 13.7.7 master mode receiving ............................................................................................................... 147 14 flash ............................................................................................................................... ................ 148 14.1 overview ............................................................................................................................... ........ 148 14.2 flash programming/erase control register ........................................................... 149 14.3 programming/erase address register ......................................................................... 149 14.4 programming/erase data register ................................................................................ 151 14.4.1 f lash i n - system - programming mapping address ..................................................................... 151 15 instruction table ................................................................................................................. 152
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 8 version 1.1 16 development tool ................................................................................................................ 153 16.1 ice (i n c ircuit e mulation )......................................................................................................... 153 16.2 SN8F2280 ev- kit .......................................................................................................................... 154 16.3 SN8F2280 t ransition b oard ...................................................................................................... 155 17 electrical characteristic ............................................................................................ 156 17.1 absolute maximum rating .............................................................................................. 156 17.2 electrical characteristic ............................................................................................. 156 18 flash rom programming pin ........................................................................................... 158 19 package information ......................................................................................................... 159 19.1 lqfp 48 pin ............................................................................................................................... ........ 159 19.2 qfn 48 pin ............................................................................................................................... ......... 160 20 marking definition ............................................................................................................... 161 20.1 introduction .......................................................................................................................... 161 20.2 marking indetification system .................................................................................... 161 20.3 marking example ................................................................................................................. 162 20.4 datecode system ................................................................................................................. 162
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 9 version 1.1 1 product overview 1.1 features ? memory configuration ? 15 interrupt sources. flash rom size : 12k x 16 bits, including in system programming function. 20000 erase/write cycles. 11 internal interrupts: t0, t1, tc0, tc1, tc2, usb, sio, i/o pin wakeup, uart, msp, a/d ram size : 512 x 8 bits. 4 external in terrupts: int0, int1, p0, p1 ? 8 levels stack buffer ? one sio function for data transfer (serial peripheral interface) ? i/o pin configuration bi-directional: p0, p1, p2, p4, p5 ? one 8 bits timer counter (t0). wakeup: p0/p1 level change. p0, p1, p2, p4, p5 with pull up function ? three 8 bits timer counter (tc0, tc1, tc2) tc0, tc1, tc2. each has 8 bit pwm function (duty/cycle programmable). external interrupt: p0, p1 (level change) p0.5, p0.6, p1.0, p1.1 with open drain function. ? one 16 bits timer counter (t1). ? full speed usb 2.0 conforms to usb specification, version 2.0 ? one channel uart function 3.3v regulated output/driving 60ma internal d+ 1.5k ohm pull-up resistor. ? one channel msp function. 1 control endpoint. 2 bi-directional int endpoints ? 8 channel 12 bit a/d function. 1 bi-directional int/bulk in endpoint. 1 bi-directional int/bulk out endpoints. ? two system clocks. external high clock: crystal type 6mhz/12mhz/16mhz programmable ep1~ep4 fifo depth internal low clock: rc type 12khz ? powerful instructions one clocks per instruction cycle (1t) ? four operating modes. most of instructions are one cycle only. normal mode: both high and low clock active slow mode: low clock only all rom area jmp instruction. sleep mode: both high and low clock stop all rom area call address instruction. green mode: periodical wakeup by timer all rom area lookup table function (movc) ? in-system re-programmability ? package allows easy firmware update lqfp48/qfn48 ? on chip watchdog timer. ) features selection table timer chip rom ram t0 t1 tc0 tc1 tc2 sio uart pwm a/d usb msp wakeup pin. i/o pin package sn8f2288 12k*16 512*8 v v v v v v v v 12bit v v 16 38 lqfp/qfn
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 10 version 1.1 1.2 system block diagram interrupt control 6mhz/12mhz/16mhz external oscillator acc internal low rc timing generator ram system registers lvd watchdog timer timer & counter alu pc flags ir flash memory full speed usb sie 3.3v regulator vreg33 d+ d- pll p0 p1 p2 p4 2.5v regulator p5 sio pwm a/d uart msp
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 11 version 1.1 1.3 pin assignment sn8f2288f (lqfp 48 pins) sn8f2288j (qfn 48 pins) p1.3 p1.4 p1.5 p1.6 p1.7 p5.5/pwm2 p5.4/pwm1 p5.3/pwm0 p5.2 p5.1 p5.0 p2.7 48 47 46 45 44 43 42 41 40 39 38 37 p1.2 1 36 p2.6 p1.1/sda 2 35 p2.5 p1.0/scl 3 34 p2.4 p0.0/int0 4 33 p2.3 p0.1/int1 5 32 p2.2/sdi p0.2 6 sn8f2288f/sn8f2288j 31 p2.1/sdo vdd 7 30 p2.0/sck p4.0/ain0 8 29 vdd p4.1/ain1 9 28 vreg33 p4.2/ain2 10 27 d- p4.3/ain3 11 26 d+ p4.4/ain4 12 25 vss 13 14 15 16 17 18 19 20 21 22 23 24 p4.5/ain5 p4.6/ain6 p4.7/ain7 vss p0.3 p0.4 p0.5/urx p0.6/utx p0.7/rst xin xout vreg25
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 12 version 1.1 1.4 pin descriptions pin name type description vdd, vss p power supply input pins for digital circuit. p0.0/int0 i/o p0.0: port 0.0 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. int0: external interrupt 0 input pin. p0.1/int1 i/o p0.1: port 0.1 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. int1: external interrupt 1 input pin. p0[4:2] i/o p0: port 0 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. p0.5/urx i/o p0.5: port 0 bi-direction pin schmitt trigger structure and built-i n pull-up resistor as input mode. built wakeup function. uart function: urx pin open drain function by control register p1oc p0.6/utx i/o p0.6: port 0 bi-direction pin schmitt trigger structure and built-i n pull-up resistor as input mode. built wakeup function. uart function: utx pin open drain function by control register p1oc p0.7/rst i/o rst is system external reset input pin under ext_rst mode, schmitt trigger structure, active ?low?, and normal stay to ?high?. built wakeup function. p1.0/scl i/o p1.0: port 1.0 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. open drain function by control register p1oc msp function: scl function p1.1/sda i/o p1.1: port 1.1 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. open drain function by control register p1oc msp function: sda function p1[7:2] i/o p1: port 1 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. built wakeup function. p2.0/sck i/o p2.0: port 2.0 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. sck: sio output clock pin. p2.1/sdo i/o p2.1: port 2.1 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. sdo: sio data output pin. p2.2/sdi i/o p2.2: port 2.2 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. sdi: sio data input pin. p2[5:3] i/o p2: port 2 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. p4[7:0]/ain[7:0] i/o p4: port 4 bi-direction pin. built-in pull-up resisters as input mode. ain[7:0]: adc channel ? 0~7 input. p5[2:0] i/o p5: port 5 bi-direction pin. schmitt trigger structure and built-in pull-up resisters as input mode. p5[5:3]/pwm2~pwm0 i/o p5: port 5 bi-direction pin.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 13 version 1.1 schmitt trigger structure and built-in pull-up resisters as input mode. pwm0, pwm1, pwm2 : pwm function xout i/o xout: oscillator output pi n while external crystal enable. xin i/o xin: oscillator input pin while exte rnal oscillator enable (crystal and rc). vreg25 p 2.5v power pin. please connect 1uf capacitor to gnd. vreg33 p 3.3v power pin. please con nect xuf capacitor to gnd. x=1~10. d+, d- i/o usb differential data line.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 14 version 1.1 1.5 pin circuit diagrams port 0, 1, 2, 4, 5 structures: pull-up pin output latch pnur input bus pnm output bus port 0.7 structure: pin ext. reset code option int. bus int. rst
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 15 version 1.1 2 central processor unit (cpu) 2.1 memory map 2.1.1 program memory (rom) ) 12k words rom rom 0000h reset vector user reset vector jump to user start address 0001h . . 0007h general purpose area 0008h interrupt vector user interrupt vector 0009h user program . . 000fh 0010h 0011h . . . . . general purpose area end of user program 2ff8h . . 2fffh reserved
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 16 version 1.1 2.1.1.1 reset vector (0000h) a one-word vector address area is used to execute system reset. ) power on reset (nt0=1, npd=0). ) watchdog reset (nt0=0, npd=0). ) external reset (nt0=1, npd=1). after power on reset, external reset or watchdog timer over flow reset, then the chip will restart the program from address 0000h an d all system registers will be set as default values . it is easy to know rese t status from nt0, npd flags of pflag register. the following example shows the way to define the reset vector in the program memory. ? example: defining reset vector org 0 ; 0000h jmp start ; jump to user program address. ? org 10h start: ; 0010h, the head of user program. ? ; user program ? endp ; end of program
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 17 version 1.1 2.1.1.2 interrupt vector (0008h) a 1-word vector address area is used to execute interrupt request. if any interrupt se rvice executes, the program counter (pc) value is stored in stack buffer and jump to 0008h of program memory to execute the vectored interrupt. users have to define the interr upt vector. the following example shows the wa y to define the interrupt vector in the program memory. ? note:?push?, ?pop? instructions save and load ac c/pflag without (nt0, npd) . push/pop buffer is a unique buffer and only one level. ? example: defining interrupt vector. the in terrupt service routine is following org 8. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine ? start: ; the head of user program. ? ; user program ? jmp start ; end of user program ? endp ; end of program
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 18 version 1.1 ? example: defining interrupt vector. the interru pt service routine is following user program. .code org 0 ; 0000h jmp start ; jump to user program address. ? org 8 ; interrupt vector. jmp my_irq ; 0008h, jump to interrupt service routine address. org 10h start: ; 0010h, the head of user program. ? ; user program. ? ? jmp start ; end of user program. ? my_irq: ;the head of interrupt service routine. push ; save acc and pflag register to buffers. ? ? pop ; load acc and pflag register from buffers. reti ; end of interrupt service routine. ? endp ; end of program. ? note: it is easy to understand the rules of sonix program from demo programs given above. these points are as following: 1. the address 0000h is a ?jmp? instruction to make the program starts from the beginning. 2. the address 0008h is interrupt vector. 3. user?s program is a loop routine for main purpose application.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 19 version 1.1 2.1.1.3 look-up table description in the rom?s data lookup function, y register is pointed to middle byte address (bit 8~bit 15) and z register is pointed to low byte address (bit 0~bit 7) of rom. after movc instruction executed, t he low-byte data will be stored in acc and high-byte data stored in r register. ? example: to look up the rom data located ?table1?. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h ; increment the index address for next address. incms z ; z+1 jmp @f ; z is not overflow. incms y ; z overflow (ffh ? 00), ? y=y+1 nop ; ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? ? note: the y register will not increase automatically wh en z register crosses boundary from 0xff to 0x00. therefore, user must take care such situation to avoid loop-up table errors. if z register overflows, y register must be added one. the following inc_yz macro shows a simple method to process y and z registers automatically. ? example: inc_yz macro. inc_yz macro incms z ; z+1 jmp @f ; not overflow incms y ; y+1 nop ; not overflow @@: endm
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 20 version 1.1 ? example: modify above exam ple by ?inc_yz? macro. b0mov y, #table1$m ; to set lookup table1?s middle address b0mov z, #table1$l ; to set lookup table1?s low address. movc ; to lookup data, r = 00h, acc = 35h inc_yz ; increment the index address for next address. ; @@: movc ; to lookup data, r = 51h, acc = 05h. ? ; table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ? the other example of loop-up table is to add y or z index register by accumulator. please be careful if ?carry? happen. ? example: increase y and z register by b0add/add instruction. b0mov y, #table1$m ; to set lookup table?s middle address. b0mov z, #table1$l ; to set lookup table?s low address. b0mov a, buf ; z = z + buf. b0add z, a b0bts1 fc ; check the carry flag. jmp getdata ; fc = 0 incms y ; fc = 1. y+1. nop getdata: ; movc ; to lookup data. if buf = 0, data is 0x0035 ; if buf = 1, data is 0x5105 ; if buf = 2, data is 0x2012 ? table1: dw 0035h ; to define a word (16 bits) data. dw 5105h dw 2012h ?
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 21 version 1.1 2.1.1.4 jump table description the jump table operation is one of multi-address jumpin g function. add low-byte program counter (pcl) and acc value to get one new pcl. if pcl is overflow after pcl+ acc, pch adds one automatically. the new program counter (pc) points to a series jump instructions as a listing t able. it is easy to make a multi-jump program depends on the value of the accumulator (a). ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: jump table. org 0x0100 ; the jump table is from the head of the rom boundary b0add pcl, a ; pcl = pcl + acc, pch + 1 when pcl overflow occurs . jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point sonix provides a macro for safe jump table function. th is macro will check the rom boundary and move the jump table to the right position automatically. the side e ffect of this macro maybe wastes some rom size. ? example: if ?jump table? crosses over rom boundary will cause errors. @jmp_a macro val if (($+1) !& 0xff00) !!= (($+(val)) !& 0xff00) jmp ($ | 0xff) org ($ | 0xff) endif add pcl, a endm ? note: ?val? is the number of the jump table listing number.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 22 version 1.1 ? example: ?@jmp_a? application in sonix macro file called ?macro3.h?. b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. jmp a0point ; acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point jmp a4point ; acc = 4, jump to a4point if the jump table position is across a rom boundary (0x00ff~ 0x0100), the ?@jmp_a? macro will adjust the jump table routine begin from next rom boundary (0x0100). ? example: ?@jmp_a? operation. ; before compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x00fd jmp a0point ; acc = 0, jump to a0point 0x00fe jmp a1point ; acc = 1, jump to a1point 0x00ff jmp a2point ; acc = 2, jump to a2point 0x0100 jmp a3point ; acc = 3, jump to a3point 0x0101 jmp a4point ; acc = 4, jump to a4point ; after compiling program. rom address b0mov a, buf0 ; ?buf0? is from 0 to 4. @jmp_a 5 ; the number of the jump table listing is five. 0x0100 jmp a0point ; acc = 0, jump to a0point 0x0101 jmp a1point ; acc = 1, jump to a1point 0x0102 jmp a2point ; acc = 2, jump to a2point 0x0103 jmp a3point ; acc = 3, jump to a3point 0x0104 jmp a4point ; acc = 4, jump to a4point
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 23 version 1.1 2.1.1.5 checksum calculation the last rom addresses are reserved area. user should av oid these addresses (last address) when calculate the checksum value. ? example: the demo program shows how to calculated checksum from 00h to the end of user?s code. mov a,#end_user_code$l b0mov end_addr1, a ; save low end address to end_addr1 mov a,#end_user_code$m b0mov end_addr2, a ; save middle end address to end_addr2 clr y ; set y to 00h clr z ; set z to 00h @@: movc b0bset fc ; clear c flag add data1, a ; add a to data1 mov a, r adc data2, a ; add r to data2 jmp end_check ; check if the yz address = the end of code aaa: incms z ; z=z+1 jmp @b ; if z != 00h calculate to next address jmp y_add_1 ; if z = 00h increase y end_check: mov a, end_addr1 cmprs a, z ; check if z = low end address jmp aaa ; if not jump to checksum calculate mov a, end_addr2 cmprs a, y ; if yes, check if y = middle end address jmp aaa ; if not jump to checksum calculate jmp checksum_end ; if yes checksum calculated is done. y_add_1: incms y ; increase y nop jmp @b ; jump to checksum calculate checksum_end: ? ? end_user_code: ; label of program end
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 24 version 1.1 2.1.2 code option table code option content function description 6mhz 6mhz crystal /resonator for external oscillator. 12mhz 12mhz crystal /resonator for external oscillator. ext_osc 16mhz 16mhz crystal /resonator for external oscillator. always_on watchdog timer is always on enable even in power down and green mode. enable enable watchdog timer. watchdog timer stops in power down mode and green mode. watch_dog disable disable watchdog function. fhosc/1 instruction cycle is 12 mhz clock. fhosc/2 instruction cycle is 6 mhz clock. fhosc/4 instruction cycle is 3 mhz clock. fcpu fhosc/8 instruction cycle is 1.5 mhz clock. reset enable external reset pin. reset_pin p07 enable p0.7 i/o function. flosc/2 slow mode clock = flosc/2. fslow flosc/4 slow mode clock = flosc/4. no no external reset de-bounce time. rst_length 128*ilrc external reset de-bounce time = 128*ilrc. lvd_l low voltage detect 1.8v. lvd_m low voltage detect 2.4v. lvd lvd_h low voltage detect 3.6v. enable enable rom code security function. security disable disable rom code security function.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 25 version 1.1 2.1.3 data memory (ram) ) 512 x 8-bit ram address ram location 000h ? ? ? ? ? 07fh general purpose area bank 0 080h ? ? ? ? ? system register bank 0 0ffh end of bank 0 area 80h~ffh of bank 0 store system registers (128 bytes). 100h ? ? ? ? ? bank1 1ffh general purpose area bank1 200h ? ? ? ? ? bank2 27fh general purpose area bank2
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 26 version 1.1 ) 136 x 8-bit ram for usb data fifo ? endpoint 0 support only control pipe ? 8 byte. ? endpoint 1 to endpoint 4, support in terrupt data transfer, bulk data tran sfer ? configurable fifo depth by setting the usb fifo control register. 136 x 8 ram (fifo) 00h ~ 07h endpoint 0 ram (8 byte) 08h endpoint 1 ram (w byte) interrupt in/out endpoint 2 ram (x byte) interrupt in/out endpoint 3 ram (y byte) interrupt in/out bulk in/out endpoint 4 ram (z byte) interrupt in/out bulk in/out
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 27 version 1.1 2.1.4 system register 2.1.4.1 system register table 0 1 2 3 4 5 6 7 8 9 a b c d e f 8 - - r z y - pflag rbank tc0m tc0c tc0r tc1m tc1c tc1r tc2m tc2c 9 tc2r uda ustat us ep0ou t_cnt usb_in t_en ep _ack ep _nak ue0r ue1r ue1r_c ue2r ue2r_c ue3r ue3r_c ue4r ue4r_c a ep2fif o_add r ep3fif o_add r ep4fif o_add r udp0 - udr0_ r udr0_ w upid utoggle urtx urrx urbrc urtxd 1 urtxd 2 urrxd 1 urrxd 2 b siom sior siob - - p0m adm adb adr p4con pecmd perom l perom h peram l peram cnt pedge c p1w p1m p2m - p4m p5m intrq1 inten1 intrq inten oscm - wdtr - pcl pch d p0 p1 p2 - p4 p5 - - t0m t0c t1m t1cl t1ch - - stkp e p0ur p1ur p2ur - p4ur p5ur - @yz - p1oc mspst at mspm1 mspm2 mspbu f mspad r - f stk7l stk7h stk6l stk6h stk5l stk5h stk4l stk4h stk3l stk3h stk2l stk2h stk1l stk1h stk0l stk0h 2.1.4.2 system regis ter description r = working register and rom look-up data buffer. y, z = working, @yz and rom addressing register. pflag = rom page and special flag register . rbank = ram bank selection register. uda = usb control register. u exr = epx control registers. uexr_c = epx byte counter register. epxfifo_a ddr = epx fifo start address of usb fifo. udp0 = usb fifo address pointer. udr0_r = usb fifo read data buffer by udp0 point to. udr0_w = usb fifo write data buffer by udp0 point to. ep_nak = endpoint nak flag register. ep_ack = endpoint ack flag register. upid = usb bus control register. utoggle = usb endpoint toggle bit control register. usb_int_en = usb interrupt enable/disable control register. ustatus = usb status register. sior = sio?s clock reload buffer ep0out_cnt = usb endpoint 0 out token data byte counter pedge = p0.0, p0.1 edge direction register. siom = sio mode control register. inten = interrupt enable register. siob = sio?s data buffer. inten1 = interrupt1 enable register. pnm = port n input/output mode register. wdtr = watchdog timer clear register. intrq = interrupt request register. pch, pcl = program counter. intrq1 = interrupt1 request register. tnm = tn mode register. n = 0, 1, c0, c1, c2 oscm = oscillator mode register. tnr = tn register. n = c0, c1, c2 tc0r = tc0 auto-reload data buffer. stkp = stack pointer buffer. pn = port n data buffer. @yz = ram yz indirect addressing index pointer. tnc = timer counting register. n = 0, 1, c0, c1, c2 stk0~stk7 = stack 0 ~ stack 7 buffer. pnur = port n pull-up resister control register. pecmd = isp command register. p1w = port 1 wakeup control register. peram = isp ram mapping address. perom = isp rom address. urtx = uart tx control regitster peramcnt = isp ram programming counter register. urbrc = uart baud rate register utrx = uart rx control register adm = a/d converter mode control register urxxdx = uart data buffer. mspstat = msp status register adb, adr = a/d converting data buffer. mspbuf = msp buffer. mspmx = msp mode register. mspadr = msp address.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 28 version 1.1 2.1.4.3 bit definition of system register address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 r/w remarks 082h rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 r/w r 083h zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 r/w z 084h ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 r/w y 086h nt0 npd c dc z r/w pflag 087h rbnks1 rbnks0 r/w rbank 088h tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks aload0 tc0out pwm0out r/w tc0m 089h tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 r/w tc0c 08ah tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 r/w tc0r 08bh tc1enb tc1rate2 tc1rate1 tc1rate0 tc1cks aload1 tc1out pwm1out r/w tc1m 08ch tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 r/w tc1c 08dh tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 r/w tc1r 08eh tc2enb tc2rate2 tc2rate1 tc2rate0 tc2cks aload2 tc2out pwm2out r/w tc2m 08fh tc2c7 tc2c6 tc2c5 tc2c4 tc2c3 tc2c2 tc2c1 tc2c0 r/w tc2c 090h tc2r7 tc2r6 tc2r5 tc2r4 tc2r3 tc2r2 tc2r1 tc2r0 r/w tc2r 091h ude uda6 uda5 uda4 uda3 uda2 uda1 uda0 r/w uda 092h crcerr pkterr sof bus_rst suspend ep0setup ep0in ep0out r/w ustatus 093h uep0oc4 uep0oc3 uep0oc2 uep0oc1 uep0oc0 r/w ep0out_cnt 094h reg_en dp_pu_en sof_int _en ep4nak _int_en ep3nak _int_en ep2nak _int_en ep1nak _int_en r/w usb_int_en 095h ep4_ack ep3_ack ep2_ack ep1_ack r/w ep_ack 096h ep4_nak ep3_nak ep2_nak ep1_nak r/w ep_nak 097h ue0m1 ue0m0 ue0c3 ue0c2 ue0c1 ue0c0 r/w ue0r 098h ue1e ue1m1 ue1m0 r/w ue1r 099h ue1c6 ue1c5 ue1c4 ue1c3 ue1c2 ue1c1 ue1c0 rw ue1r_c 09ah ue2e ue2m1 ue2m0 r/w ue2r 09bh ue2c6 ue2c5 ue2c4 ue2c3 ue2c2 ue2c1 ue2c0 rw ue2r_c 09ch ue3e ue3m1 ue3m0 r/w ue3r 09dh ue3c6 ue3c5 ue3c4 ue3c3 ue3c2 ue3c1 ue3c0 rw ue3r_c 09eh ue4e ue4m1 ue4m0 r/w ue4r 09fh ue4c6 ue4c5 ue4c4 ue4c3 ue4c2 ue4c1 ue4c0 rw ue4r_c 0a0h ep2fifo7 ep2fifo6 ep2fifo5 ep2fifo4 ep2fifo3 ep2fifo2 ep2fifo1 ep2fifo0 r/w ep2fifo_addr 0a1h ep3fifo7 ep3fifo6 ep3fifo5 ep3fifo4 ep3fifo3 ep3fifo2 ep3fifo1 ep3fifo0 r/w ep3fifo_addr 0a2h ep4fifo7 ep4fifo6 ep4fifo5 ep4fifo4 ep4fifo3 ep4fifo2 ep4fifo1 ep4fifo0 r/w ep4fifo_addr 0a3h udp07 udp06 udp05 udp04 udp03 udp02 udp01 udp00 r/w udp0 0a5h udr0_r7 udr0_r6 udr0_r5 udr0_r4 udr0_r3 udr0_r2 udr0_r1 udr0_r0 r/w udr0_r 0a6h udr0_w7 udr0_w6 udr0_w5 udr0_w4 udr0_w3 udr0_w2 udr0_w1 udr0_w0 r/w udr0_w 0a7h ubde ddp ddn r/w upid 0a8h ep4_data 01 ep3_data 01 ep2_data 01 ep1_data 01 r/w utoggle 0a9h uclks utxen utxpen utxps utxm r/w urtx 0aah urxen urxs1 urxs0 urxpen urxps urxpc urxm r/w urrx 0abh udiv4 udiv3 udiv2 udiv1 udiv0 upcs2 upcs1 upcs0 r/w urbrc 0ach utxd17 utxd16 utxd15 utxd14 utxd13 utxd12 utxd11 utxd10 r/w urtxd1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 29 version 1.1 0adh utxd27 utxd26 utxd25 utxd24 utxd23 utxd22 utxd21 utxd20 r/w urtxd2 0aeh urxd17 urxd16 urxd15 urxd14 urxd13 urxd12 urxd11 urxd10 r urrxd1 0afh urxd27 urxd26 urxd25 urxd24 urxd23 urxd22 urxd21 urxd20 r urrxd2 0b0h senb start srate1 srate0 mlsb sckmd cpol cpha r/w siom 0b1h sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 w sior 0b2h siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 r/w siob 0b5h p07m p06m p05m p04m p03m p02m p01m p00m r/w p0m 0b6h adenb ads eoc gchs chs3 chs2 chs1 chs0 r/w adm 0b7h adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 r/w adb 0b8h adcks2 adcks1 adcks0 adlen adb3 adb2 adb1 adb0 rw adr 0b9h p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 r/w p4con 0bah pecmd7 pecmd6 pecmd5 pecmd4 pec md3 pecmd2 pecmd1 pecmd0 w pecmd 0bbh peroml7 peroml6 peroml5 peroml4 peroml3 peroml2 peroml1 peroml0 r/w peroml 0bch peromh7 peromh6 peromh5 peromh4 peromh3 peromh2 peromh1 peromh0 r/w peromh 0bdh peraml7 peraml6 peraml5 peraml4 peraml3 peraml2 peraml1 peraml0 r/w peraml 0beh peramcnt 4 peramcnt 3 peramcnt 2 peramcnt 1 peramcnt 0 peraml9 peraml8 r/w peramcnt 0bfh p01g1 p01g0 p00g1 p00g0 r/w pedge 0c0h p17w p16w p15w p14w p 13w p12w p11w p10w r/w p1w 0c1h p17m p16m p15m p14m p13m p12m p11m p10m r/w p1m 0c2h p27m p26m p25m p24m p23m p22m p21m p20m r/w p2m 0c4h p47m p46m p45m p44m p43m p42m p41m p40m r/w p4m 0c5h p55m p54m p53m p52m p51m p50m r/w p5m 0c6h p1irq p0irq mspirq utrxirq uttxirq t2cirq tc1irq tc0irq r/w intrq1 0c7h p1ien p0ien mspien utrxien uttxien tc2ien tc1ien tc0ien r/w inten1 0c8h adcirq usbirq t1irq t0irq sioirq wakeirq p01irq p00irq r/w intrq 0c9h adcien usbien t1ien t0ien sioien wakeien p01ien p00ien r/w inten 0cah cpum1 cpum0 clkmd stphx r/w oscm 0cch wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 w wdtr 0ceh pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 r/w pcl 0cfh pc13 pc12 pc11 pc10 pc9 pc8 r/w pch 0d0h p07 p06 p05 p04 p03 p02 p01 p00 r/w p0 0d1h p17 p16 p15 p14 p13 p12 p11 p10 r/w p1 0d2h p27 p26 p25 p24 p23 p22 p21 p10 r/w p2 0d4h p47 p46 p45 p44 p43 p42 p41 p40 r/w p4 0d5h p55 p54 p53 p52 p51 p50 r/w p5 0d8h t0enb t0rate2 t0rate1 t0rate0 r/w t0m 0d9h t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 r/w t0c 0dah t1enb t1rate2 t1rate1 t1rate0 r/w t1m 0dbh t1c7 t1c6 t1c5 t1c4 t1c3 t1c2 t1c1 t1c0 r/w t1cl 0dch t1c15 t1c14 t1c13 t1c12 t1c11 t1c10 t1c9 t1c8 r/w t1ch 0dfh gie stkpb2 stkpb1 stkpb0 r/w stkp 0e0h p07r p06r p05r p04r p03r p02r p01r p00r w p0ur 0e1h p17r p16r p15r p14r p13r p12r p11r p10r w p1ur 0e2h p27r p26r p25r p24r p23r p22r p21r p20r w p2ur 0e4h p47r p46r p45r p44r p43r p42r p41r p40r w p4ur 0e5h p55r p54r p53r p52r p51r p50r w p5ur 0e7h @yz7 @yz6 @yz5 @yz4 @yz3 @yz2 @yz1 @yz0 r/w @yz 0e9h p06oc p05oc p11oc p10oc r/w p1oc 0eah cke d_a p s red_wrt bf r mspstat 0ebh wcol mspov mspenb ckp slrxckp mspwk mspc r/w mspm1 0ech gcen ackstat ackdt acken rcen pen rsen sen r/w mspm2 0edh mspbuf7 mspbuf6 mspbuf5 mspbuf4 mspbuf3 mspbuf2 mspbuf1 mspbuf0 r/w mspbuf 0eeh mspadr7 mspadr6 mspadr5 mspadr4 mspadr3 mspadr2 mspadr1 mspadr0 r/w mspadr 0f0h s7pc7 s7pc6 s7pc5 s7pc4 s7pc3 s7pc2 s7pc1 s7pc0 r/w stk7l 0f1h s7pc13 s7pc12 s7pc11 s7pc10 s7pc9 s7pc8 r/w stk7h 0f2h s6pc7 s6pc6 s6pc5 s6pc4 s6pc3 s6pc2 s6pc1 s6pc0 r/w stk6l 0f3h s6pc13 s6pc12 s6pc11 s6pc10 s6pc9 s6pc8 r/w stk6h 0f4h s5pc7 s5pc6 s5pc5 s5pc4 s5pc3 s5pc2 s5pc1 s5pc0 r/w stk5l 0f5h s5pc13 s5pc12 s5pc11 s5pc10 s5pc9 s5pc8 r/w stk5h 0f6h s4pc7 s4pc6 s4pc5 s4pc4 s4pc3 s4pc2 s4pc1 s4pc0 r/w stk4l 0f7h s4pc13 s4pc12 s4pc11 s4pc10 s4pc9 s4pc8 r/w stk4h 0f8h s3pc7 s3pc6 s3pc5 s3pc4 s3pc3 s3pc2 s3pc1 s3pc0 r/w stk3l 0f9h s3pc13 s3pc12 s3pc11 s3pc10 s3pc9 s3pc8 r/w stk3h 0fah s2pc7 s2pc6 s2pc5 s2pc4 s2pc3 s2pc2 s2pc1 s2pc0 r/w stk2l 0fbh s2pc13 s2pc12 s2pc11 s2pc10 s2pc9 s2pc8 r/w stk2h 0fch s1pc7 s1pc6 s1pc5 s1pc4 s1pc3 s1pc2 s1pc1 s1pc0 r/w stk1l
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 30 version 1.1 0fdh s1pc13 s1pc12 s1pc11 s1pc10 s1pc9 s1pc8 r/w stk1h 0feh s0pc7 s0pc6 s0pc5 s0pc4 s0pc3 s0pc2 s0pc1 s0pc0 r/w stk0l 0ffh s0pc13 s0pc12 s0pc11 s0pc10 s0pc9 s0pc8 r/w stk0h ? note: 1. to avoid system error, please be sure to put all the ?0? and ?1? as it indicates in the above table . 2. all of register names had been declared in sn8asm assembler. 3. one-bit name had been declared in sn8asm assembler with ?f? prefix code. 4. ?b0bset?, ?b0bclr?, ?bset?, ?bclr? instructi ons are only available to the ?r/w? registers. 5. for detail description, please refer to the ?system register quick reference table? .
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 31 version 1.1 2.1.4.4 accumulator the acc is an 8-bit data register responsible for trans ferring or manipulating data between alu and data memory. if the result of operating is zero (z) or there is carry (c or dc) occurrence, then these flags will be set to pflag register. acc is not in data memory (ram), so acc can?t be acce ss by ?b0mov? instruction dur ing the instant addressing mode. ? example: read and write acc value. ; read acc data and store in buf data memory. mov buf, a ; write a immediate data into acc. mov a, #0fh ; write acc data from buf data memory. mov a, buf ; or b0mov a, buf the system doesn?t store acc and pfla g value when interrupt executed. a cc and pflag data must be saved to other data memories. ?push?, ?pop? save and load acc, pflag data into buffers. ? example: protect acc and working registers. int_service: push ; save acc and pflag to buffers. ? . ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 32 version 1.1 2.1.4.5 program flag the pflag register contains the arithm etic status of alu operat ion; system reset status and lvd detecting status. nt0, npd bits indicate system reset status including po wer on reset, lvd reset, reset by external pin active and watchdog reset. c, dc, z bits indicate t he result status of alu operation. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd - - - c dc z read/write r/w r/w - - - r/w r/w r/w after reset - - - - - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd reset status 0 0 watch-dog time out 0 1 reserved 1 0 reset by lvd 1 1 reset by external reset pin bit 2 c: carry flag 1 = addition with carry, subtraction without borrowing, ro tation with shifting out logic ?1?, comparison result 0. 0 = addition without carry, s ubtraction with borrowing signal, rotation wi th shifting out logic ?0?, comparison result < 0. bit 1 dc: decimal carry flag 1 = addition with carry from low nibble, subtraction without borrow from high nibble. 0 = addition without carry from low nibble, subtraction with borrow from high nibble. bit 0 z: zero flag 1 = the result of an arithmetic/logic/branch operation is zero. 0 = the result of an arithmetic/logic/branch operation is not zero. ? note: refer to instruction set table for detailed information of c, dc and z flags.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 33 version 1.1 2.1.4.6 program counter the program counter (pc) is a 14-bit binary counter sepa rated into the high-byte 6 and the low-byte 8 bits. this counter is responsible for pointing a location in order to fe tch an instruction for kernel circuit. normally, the program counter is automatically incremented with eac h instruction during program execution. besides, it can be replaced with specific address by execut ing call or jmp instruction. when jmp or call instruction is executed, the desti nation address will be inserted to bit 0 ~ bit 13. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pc - - pc13 pc12 pc11 pc10 pc9 pc8 pc7 pc6 pc5 pc4 pc3 pc2 pc1 pc0 after reset - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pch pcl ) one address skipping there are nine instructions (cmprs, incs, incms, de cs, decms, bts0, bts1, b0bts0, b0bts1) with one address skipping function. if the result of these instructions is true, the pc will add 2 steps to skip next instruction. if the condition of bit test instruction is true, the pc will add 2 steps to skip next instruction. b0bts1 fc ; to skip, if carry_flag = 1 jmp c0step ; else jump to c0step. ? ? c0step: nop b0mov a, buf0 ; move buf0 value to acc. b0bts0 fz ; to skip, if zero flag = 0. jmp c1step ; else jump to c1step. ? ? c1step: nop if the acc is equal to the immediat e data or memory, the pc will add 2 steps to skip next instruction. cmprs a, #12h ; to skip, if acc = 12h. jmp c0step ; else jump to c0step. ? ? c0step: nop
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 34 version 1.1 if the destination increased by 1, wh ich results overflow of 0xff to 0x00, the pc will add 2 steps to skip next instruction. incs instruction: incs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop incms instruction: incms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop if the destination decreased by 1, which results underflo w of 0x00 to 0xff, the pc will add 2 steps to skip next instruction. decs instruction: decs buf0 jmp c0step ; jump to c0step if acc is not zero. ? ? c0step: nop decms instruction: decms buf0 jmp c0step ; jump to c0step if buf0 is not zero. ? ? c0step: nop
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 35 version 1.1 ) multi-address jumping users can jump around the mult i-address by either jmp inst ruction or add m, a instruction (m = pcl) to activate multi-address jumping function. program counter supports ?add m,a? , ?adc m,a? and ?b0add m,a? instructions for carry to pch when pcl overflow automatically. for jump t able or others applications, users can calculate pc value by the three instructions and don?t care pcl overflow problem. ? note: pch only support pc up counting result and doesn?t support pc down counting. when pcl is carry after pcl+acc, pch adds one automatically. if pcl borrow after pcl?acc, pch keeps value and not change. ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h mov a, #28h b0mov pcl, a ; jump to address 0328h ? ; pc = 0328h mov a, #00h b0mov pcl, a ; jump to address 0300h ? ? example: if pc = 0323h (pch = 03h, pcl = 23h) ; pc = 0323h b0add pcl, a ; pcl = pcl + ac c, the pch cannot be changed. jmp a0point ; if acc = 0, jump to a0point jmp a1point ; acc = 1, jump to a1point jmp a2point ; acc = 2, jump to a2point jmp a3point ; acc = 3, jump to a3point ? ?
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 36 version 1.1 2.1.4.7 y, z registers the y and z registers are the 8-bit buffers. there ar e three major functions of these registers. z can be used as general working registers z can be used as ram data pointers with @yz register z can be used as rom data pointer with the movc instruction for look-up table 084h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 y ybit7 ybit6 ybit5 ybit4 ybit3 ybit2 ybit1 ybit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - 083h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 z zbit7 zbit6 zbit5 zbit4 zbit3 zbit2 zbit1 zbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - example: uses y, z register as the data pointer to access data in the ram address 025h of bank0. b0mov y, #00h ; to set ram bank 0 for y register b0mov z, #25h ; to set location 25h for z register b0mov a, @yz ; to read a data into acc example: uses the y, z register as data pointer to clear the ram data. b0mov y, #0 ; y = 0, bank 0 b0mov z, #07fh ; z = 7fh, the last address of the data memory area clr_yz_buf: clr @yz ; clear @yz to be zero decms z ; z ? 1, if z= 0, finish the routine jmp clr_yz_buf ; not zero clr @yz end_clr: ; end of clear general purpose data memory area of bank 0 ?
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 37 version 1.1 2.1.4.8 r registers r register is an 8-bit buffer. there are two major functions of the register. z can be used as working register z for store high-byte data of look-up table (movc instruction executed, the high- byte data of specified rom address will be stored in r register and the low-byte data will be stored in acc). 082h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 r rbit7 rbit6 rbit5 rbit4 rbit3 rbit2 rbit1 rbit0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset - - - - - - - - ? note: please refer to the ?look-up table description? about r regi ster look-up table application.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 38 version 1.1 2.2 addressing mode 2.2.1 immediate addressing mode the immediate addressing mode uses an immediate data to set up the location in acc or specific ram. ? example: move the immediate data 12h to acc. mov a, #12h ; to set an immediate data 12h into acc. ? example: move the immediate data 12h to r register. b0mov r, #12h ; to set an immediate data 12h into r register. ? note: in immediate addressing mode application, th e specific ram must be 0x80~0x87 working register. 2.2.2 directly addressing mode the directly addressing mode moves the cont ent of ram location in or out of acc. ? example: move 0x12 ram location data into acc. b0mov a, 12h ; to get a content of ram location 0x12 of bank 0 and save in acc. ? example: move acc data into 0x12 ram location. b0mov 12h, a ; to get a content of acc and save in ram location 12h of bank 0. 2.2.3 indirectly addressing mode the indirectly addressing mode is to access the memory by the data pointer registers (y/z). ? example: indirectly addressing mode with @yz register. b0mov y, #0 ; to clear y register to access ram bank 0. b0mov z, #12h ; to set an immediate data 12h into z register. b0mov a, @yz ; use data pointer @yz reads a data from ram location ; 012h into acc.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 39 version 1.1 2.3 stack operation 2.3.1 overview the stack buffer has 8-level. these buffers are designed to push and pop up program counter?s (pc) data when interrupt service routine and ?call? inst ruction are executed. the stkp register is a pointer designed to point active level in order to push or pop up data from stack buffer. the stknh and stknl are the stack buffers to store program counter (pc) data. ret / reti call / interrupt stkp = 7 stkp = 6 stkp = 5 stkp = 4 stack level stk7h stk6h stk5h stk4h stack buffer high byte pch stkp stk7l stk6l stk5l stk4l stack buffer low byte pcl stkp stkp - 1 stkp + 1 stkp = 3 stkp = 2 stkp = 1 stkp = 0 stk3l stk2l stk1l stk0l stk3h stk2h stk1h stk0h
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 40 version 1.1 2.3.2 stack registers the stack pointer (stkp) is a 3-bit register to store t he address used to access the st ack buffer, 14-bit data memory (stknh and stknl) set aside for temp orary storage of stack addresses. the two stack operations are writing to the top of the stac k (push) and reading from the top of stack (pop). push operation decrements the stkp and the pop operation increments each time. that makes the stkp always point to the top address of stack buffer and wr ite the last program counter val ue (pc) into the stack buffer. the program counter (pc) value is stored in the stack bu ffer before a call instruction ex ecuted or during interrupt service routine. stack operation is a lifo type (last in and first out). the stack pointer (stkp) and stack buffer (stknh and stknl) are located in t he system register area bank 0. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 7 gie: global interrupt control bit. 0 = disable. 1 = enable. please refer to the interrupt chapter. bit[2:0] stkpbn: stack pointer (n = 0 ~ 2) ? example: stack pointer (stkp) reset, we strongl y recommended to clear the stack pointers in the beginning of the program. mov a, #00000111b b0mov stkp, a 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknh - - snpc13 snpc12 snpc11 snpc10 snpc9 snpc8 read/write - - r/w r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 0f0h~0ffh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stknl snpc7 snpc6 snpc5 snpc4 snpc3 snpc2 snpc1 snpc0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 stkn = stknh , stknl (n = 7 ~ 0)
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 41 version 1.1 2.3.3 stack operation example the two kinds of stack-save operations refer to the stack pointer (stkp) and writ e the content of program counter (pc) to the stack buffer are call instructi on and interrupt service. under each condition, the stkp decreases and points to the next available stack location. the stack buffer stor es the program counter about the op-code address. the stack-save operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 0 1 1 1 free free - 1 1 1 0 stk0h stk0l - 2 1 0 1 stk1h stk1l - 3 1 0 0 stk2h stk2l - 4 0 1 1 stk3h stk3l - 5 0 1 0 stk4h stk4l - 6 0 0 1 stk5h stk5l - 7 0 0 0 stk6h stk6l - 8 1 1 1 stk7h stk7l - > 8 1 1 0 - - stack over, error there are stack-restore operations correspond to each push operation to restore the prog ram counter (pc). the reti instruction uses for interrupt service routine. the ret inst ruction is for call instruction. when a pop operation occurs, the stkp is incremented and points to the next free stack loca tion. the stack buffer restores the last program counter (pc) to the program counter registers. the stac k-restore operation is as the following table. stkp register stack buffer stack level stkpb2 stkpb1 stkpb0 high byte low byte description 8 1 1 1 stk7h stk7l - 7 0 0 0 stk6h stk6l - 6 0 0 1 stk5h stk5l - 5 0 1 0 stk4h stk4l - 4 0 1 1 stk3h stk3l - 3 1 0 0 stk2h stk2l - 2 1 0 1 stk1h stk1l - 1 1 1 0 stk0h stk0l - 0 1 1 1 free free -
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 42 version 1.1 3 reset 3.1 overview the system would be reset in three conditions as following. z power on reset z watchdog reset z brown out reset z external reset (only supports external reset pin enable situation) when any reset condition occurs, all syst em registers keep initial status, progra m stops and program counter is cleared. after reset status released, the system boots up and progra m starts to execute from org 0. the nt0, npd flags indicate system reset status. the system can depend on nt0, npd status and go to diffe rent paths by program. 086h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pflag nt0 npd - - - c dc z read/write r/w r/w - - - r/w r/w r/w after reset - - - - - 0 0 0 bit [7:6] nt0, npd: reset status flag. nt0 npd condition description 0 0 watchdog reset watchdog timer overflow. 0 1 reserved - 1 0 power on reset and lvd reset. power voltage is lower than lvd detecting level. 1 1 external reset external reset pin detect low level status.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 43 version 1.1 finishing any reset sequence needs some time. the system provides complete procedures to make the power on reset successful. for different oscillat or types, the reset time is different. that causes the vdd rise rate and start-up time of different oscillator is not fixed. rc ty pe oscillator?s start-up time is very shor t, but the crystal type is longer. under clie nt terminal application, users have to take care the power on reset time for the master terminal requirement. the reset timing diagram is as following. vdd vss vdd vss watchdog normal run watchdog stop system normal run system stop lvd detect level external reset low detect external reset high detect watchdog overflow watchdog reset delay time external reset delay time power on delay time power external reset watchdog reset system status
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 44 version 1.1 3.2 power on reset the power on reset depend no lvd operation for most power-up situations. the power supplying to system is a rising curve and needs some time to achieve the normal voltage. power on reset sequence is as following. z power-up: system detects the power voltage up and waits for power stable. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset status and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. 3.3 watchdog reset watchdog reset is a system protection. in normal condition, system works well and clears watchdog timer by program. under error condition, system is in unknown situation and watchdog can?t be clear by program before watchdog timer overflow. watchdog timer overflow occurs and the system is reset. after watchdog reset, the system restarts and returns normal mode. watchdog reset sequence is as following. z watchdog timer status: system checks watchdog timer overflow stat us. if watchdog timer ov erflow occurs, the system is reset. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? note: please refer to the ?watchdog timer? about watchdog timer detail information.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 45 version 1.1 3.4 brown out reset 3.4.1 brown out description the brown out reset is a power dropping condition. the powe r drops from normal voltage to low voltage by external factors (e.g. eft interference or extern al loading changed). the brown out reset would make the system not work well or executing program error. vdd vss v1 v2 v3 system work well area system work error area brown out reset diagram the power dropping might through the voltage range that ?s the system dead-band. the dead-band means the power range can?t offer the system minimum operation power re quirement. the above diagram is a typical brown out reset diagram. there is a serious noise under the vdd, and vdd voltage drops very deep. there is a dotted line to separate the system working area. the above area is the system work well area. the below area is the system work error area called dead-band. v1 doesn?t touch the below area and not effe ct the system operation. but the v2 and v3 is under the below area and may induce the system error occurrence. let system under dead-band includes some conditions. dc application: the power source of dc application is usually using battery . when low battery condition and mcu drive any loading, the power drops and keeps in dead-band. under the situat ion, the power won?t drop dee per and not touch the system reset voltage. that makes the system under dead-band. ac application: in ac power application, the dc power is regulated from ac power source. this kind of power usually couples with ac noise that makes the dc power dirty. or the external loading is very heavy, e. g. driving motor. the loading operating induces noise and overlaps with the dc power. vdd drop s by the noise, and the system works under unstable power situation. the power on duration and power down duration are longer in ac application. the system power on sequence protects the power on successful, but the power do wn situation is like dc low battery condition. when turn off the ac power, the vdd drops slowly and through the dead-band for a while.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 46 version 1.1 3.4.2 the system operat ing voltage decsription to improve the brown out reset needs to know the system minimum operating voltage which is depend on the system executing rate and power level. differe nt system executing rates have differe nt system minimum operating voltage. the electrical characteristic section shows the system voltage to executing rate relationship. vdd (v) system rate (fcpu) system mini. operating voltage. system reset voltage. dead-band area normal operating area reset area normally the system operation voltage ar ea is higher than the system reset voltage to vdd, and the reset voltage is decided by lvd detect level. the system minimum operating voltage rises when the system executing rate upper even higher than system reset voltage. the dead-band definition is the system minimum operat ing voltage above the system reset voltage.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 47 version 1.1 3.4.3 brown out reset improvement how to improve the brown reset condition? there are some methods to improve brown out reset as following. z lvd reset z watchdog reset z reduce the system executing rate z external reset circuit. (zener diode reset circuit, voltage bias reset circuit, external reset ic) ? note: 1. the ? zener diode reset circuit?, ?volta g e bias reset circuit? and ?external reset ic? can completely improve the brown out reset, dc low battery and ac slow power down conditions. 2. for ac power application and enhance eft performance, the system clock is 4mhz/4 ( 1 mips ) and use external reset ( ? zener diode reset circuit?, ?volta g e bias reset circuit?, ?external reset ic?). the structure can improve noise effective and get good eft characteristic. lvd reset: vdd vss system normal run system stop lvd detect voltage power on delay time power system status power is below lvd detect voltage and system reset. the lvd (low voltage detector) is built-in sonix 8-bit mcu to be brown out reset protection. when the vdd drops and is below lvd detect voltage, the lvd would be triggered, an d the system is reset. the lvd detect level is different by each mcu. the lvd voltage level is a point of volt age and not easy to cover all dead-band range. using lvd to improve brown out reset is depend on application requiremen t and environment. if the power variation is very deep, violent and trigger the lvd, the lvd ca n be the protection. if the power variation can touch the lvd detect level and make system work error, the lvd can? t be the protection and need to other reset methods. more detail lvd information is in the electrical characteristic section. watchdog reset: the watchdog timer is a protection to make sure the system executes well. normally the watchdog timer would be clear at one point of program. don?t clear the watchdog timer in several addresses. the system executes normally and the watchdog won?t reset system. when the system is under dea d-band and the execution error, the watchdog timer can?t be clear by program. the watchdog is continuously counting until overflow occurrence. the overflow signal of watchdog timer triggers the system to reset, and the system return to normal mode after reset sequence. this method also can improve brown out reset condition and make sure the system to return normal mode. if the system reset by watchdog and the power is still in dead-band, the system reset sequence won?t be successful and the system stays in reset status until the power return to normal range. reduce the system executing rate: if the system rate is fast and the dead-band exists, to redu ce the system executing rate can improve the dead-band. the lower system rate is with lower minimum operating voltage. select the power voltage that?s no dead-band issue and find out the mapping system rate. adjust the system ra te to the value and the syst em exits the dead-band issue. this way needs to modify whole program timing to fit the application requirement. external reset circuit: the external reset methods also can improve brown out rese t and is the complete solution. there are three external reset circuits to improve brown out reset including ?zener di ode reset circuit?, ?voltage bias reset circuit? and ?external reset ic?. these three reset structures use external rese t signal and control to make sure the mcu be reset under power dropping and under dead-band. the external rese t information is described in the next section.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 48 version 1.1 3.5 external reset external reset function is controlled by ?reset_pin? code option. set the code option as ?reset? option to enable external reset function. external reset pin is schmitt trigge r structure and low level active. the system is running when reset pin is high level voltage input. the reset pin receives the low voltage and the system is reset. the external reset operation actives in power on and normal running mode. duri ng system power-up, the external reset pin must be high level input, or the system keeps in reset stat us. external reset sequence is as following. z external reset (only external reset pin enable): system checks external reset pin status. if external reset pin is not high level, the system keeps reset status and waits external reset pin released. z system initialization: all system registers is set as initia l conditions and system is ready. z oscillator warm up: oscillator operation is successfully and supply to system clock. z program executing: power on sequence is finished and program executes from org 0. the external reset can reset the system during power on duration, and good external reset circuit can protect the system to avoid working at unusual power condition, e.g. brown out reset in ac power application? 3.6 external reset circuit 3.6.1 simply rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf r2 100 ohm this is the basic reset circuit, and only includes r1 and c1. the rc circuit operation makes a slow rising signal into reset pin as power up. the reset signal is slower than vdd power up timing, and system occurs a power on signal from the timing difference. ? note: the reset circuit is no any protection against unusual power or brown out reset.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 49 version 1.1 3.6.2 diode & rc reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm c1 0.1uf diode r2 100 ohm this is the better reset circuit. the r1 and c1 circuit operation is like the simply reset circuit to make a power on signal. the reset circuit has a simply protection against unusual po wer. the diode offers a power positive path to conduct higher power to vdd. it is can make reset pin voltage le vel to synchronize with v dd voltage. the structure can improve slight brown out reset condition. ? note: the r2 100 ohm resistor of ?simpl y reset circuit? and ?diode & rc reset circuit? is necessar y to limit any current flowing into reset pin from external capacitor c in the event of reset pin breakdown due to electrostatic discharge (esd) or electrical over-stress (eos). 3.6.3 zener diode reset circuit mcu vdd vss vcc gnd r s t r1 33k ohm r3 40k ohm r2 10k ohm vz q1 e c b the zener diode reset circuit is a simple low voltage detector and can improve brown out reset condition completely . use zener voltage to be the active level. when vdd vo ltage level is above ?vz + 0. 7v?, the c terminal of the pnp transistor outputs high voltage and mcu operates normal ly. when vdd is below ?vz + 0.7v?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by zener specification. select the right zene r voltage to conform the application.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 50 version 1.1 3.6.4 voltage bias reset circuit mcu vdd vss vcc gnd r s t r1 47k ohm r3 2k ohm r2 10k ohm q1 e c b the voltage bias reset circuit is a low cost voltage detector and can improve brown out reset condition completely . the operating voltage is not accurate as zener diode reset ci rcuit. use r1, r2 bias voltage to be the active level. when vdd voltage level is above or equal to ?0.7v x (r1 + r2) / r1?, the c terminal of the pnp transistor outputs high voltage and mcu operates normally. when vdd is below ?0.7v x (r 1 + r2) / r1?, the c terminal of the pnp transistor outputs low voltage and mcu is in reset mode. decide the reset detect voltage by r1, r2 resistances. select the right r1, r2 value to conform the application. in the circuit diagram condition, the mcu?s reset pin level varies with vdd voltage variation, and the differential voltage is 0.7v. if the vdd drops and the voltage lower than reset pin det ect level, the system would be reset. if want to make the reset active earlier, set the r2 > r1 and the cap between vdd and c terminal voltage is larger than 0.7v. the external reset circuit is with a stable current through r1 and r2. for power consumption issue application, e.g. dc power system, the current must be considered to whole system power consumption. ? note: under unstable power condition as brown out reset , ?zener diode reset circuit? and ?voltage bias reset circuit? can protects s y stem no an y error occurrence as power droppin g . when power drops below the reset detect volta g e, the s y stem reset would be tri gg ered, and then s y stem executes reset sequence. that makes sure the system work well under unstable power situation. 3.6.5 external reset ic mcu vdd vss vcc gnd r s t reset ic vdd vss rst bypass capacitor 0.1uf the external reset circuit also use external reset ic to enhance mcu reset performance. this is a high cost and good effect solution. by different application and system require ment to select suitable reset ic. the reset circuit can improve all power variation
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 51 version 1.1 4 system clock 4.1 overview the micro-controller is a dual clock sy stem. there are high-speed clock and low-speed clock. the high-speed clock is generated from the external oscillator & on-chip pll circui t. the low-speed clock is generated from on-chip low-speed rc oscillator circuit (ilrc 12 khz). both the high-speed clock and the low-sp eed clock can be system clock (fosc). the system clock in slow mode is divided by 2 or 4 to be the instruction cycle (fcpu). ) normal mode (high clock): fcpu = fhosc / n , n = 1 ~ 8, select n by fcpu code option. ) slow mode (low clock): fcpu = flosc/n, n = 2 or 4, select n by code option. sonix provides a ?noise filter? controlled by code option. in high noisy sit uation, the noise filter can isolate noise outside and protect system works well. the minimum fcpu of high clock is limited at fhosc/4 when noise filter enable. 4.2 clock block diagram fhosc. fcpu = fhosc/1 ~ fhosc/8, noise filter disable. fcpu = fhosc/4, noise filter enable. flosc. fcpu = flosc/2 or flosc/4 cpum[1:0] xin xout stphx hosc fcpu code option fosc fosc clkmd fcpu z hosc: high_clk code option. z fhosc: external high-speed clock. z flosc: internal low-speed rc clock (typical 12 khz). z fosc: system clock source. z fcpu: instruction cycle.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 52 version 1.1 4.3 oscm register the oscm register is an oscillator control regi ster. it controls oscillator status, system mode. 0cah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 oscm - - - cpum1 cpum0 clkmd stphx - read/write - - - r/w r/w r/w r/w - after reset - - - 0 0 0 0 - bit[4:3] cpum[1:0]: cpu operating mode control bits. 00 = normal. 01 = sleep (power down) mode. 10 = green mode. 11 = reserved. bit 2 clkmd: system high/low clock mode control bit. 0 = normal (dual) mode. syst em clock is high clock. 1 = slow mode. system clock is internal low clock. bit 1 stphx: external high-speed os cillator control bit. 0 = external high-speed oscillator free run. 1 = external high-speed oscillator free run stop. internal low-speed rc oscillator is still running. ? example: stop high-speed oscillator and pll circuit. b0bset fstphx ; to stop exter nal high-speed oscillator only. example: when entering the power down mode (sleep mo de), both high-speed extern al oscillator, pll circuit and internal low-speed o scillator will be stopped. b0bset fcpum0 ; to stop external high-speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode).
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 53 version 1.1 4.4 system high clock the system high clock is from the in circ uit pll. user must select the external oscillator 6mhz x?tal, 12mhz x?tal or 16mhz x?tal by the code option ?ext_osc?, and all the three clock source will input to the on-chip pll circuit. pll will output 12mhz to system clock (fosc). 4.4.1 external high clock external high clock includes three modules (crystal/ceramic an d external clock signal). the start up time of crystal and ceramic oscillator is different. the oscillator start-up time decide s reset time length.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 54 version 1.1 4.4.1.1 crystal/ceramic crystal/ceramic devices are driven by xin, xout pins. ? note: connect the crystal/ceramic and c as near as po ssible to the xin/xout/vss pins of micro-controller.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 55 version 1.1 4.1.1.2 external clock signal selecting external clock signal input to be the input clock source is by the ?ext _osc? code option. the external clock signal is input from xin pin. xout pin is general purpose i/o pin. mcu vcc gnd vss vdd xin xout external clock input ? note: the gnd of exte rnal oscillator circuit must be as near as possible to vss pin of micro-controller.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 56 version 1.1 4.2 system low clock the system low clock source is the internal low-speed oscill ator built in the micro-contro ller. the low-sp eed oscillator uses rc type oscillator circuit. the frequency is affect ed by the voltage and temperature of the system. in common condition, the frequency of the rc oscillator is about 12khz. the internal low rc supports watchdog clock source and system slow mode controlled by clkmd. ) flosc = internal low rc oscillator (12khz). ) slow mode fcpu = flosc / n. n = 2 or 4 set by code option. there are two conditions to stop internal low rc. one is power down mode, and the other is green mode of 12k mode and watchdog disable. if system is in 12k mode and watchdog disable, only 12k oscillator actives and system is under low power consumption. ? example: stop internal low-speed oscillator by power down mode. b0bset fcpum0 ; to stop external high-speed oscillator and in ternal low-speed ; oscillator called powe r down mode (sleep mode). ? note: the internal low-speed clock can?t be turned off individually. it is controlled by cpum0, cpum1 (12k, watchdog disable) bits of oscm register.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 57 version 1.1 4.2.1 system clock measurement under design period, the users can meas ure system clock speed by software instruction cycle (fcpu). this way is useful in rc mode. example: fcpu instruction cycl e of external oscillator. b0bset p0m.0 ; set p0.0 to be output mode for outputting fcpu toggle signal. @@: b0bset p0.0 ; output fcpu toggle signal in low-sp eed clock mode. b0bclr p0.0 ; measure the fcpu frequency by oscilloscope. jmp @b ? note: do not measure the rc frequency directly from xin; the probe impendence will affect the rc frequency.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 58 version 1.1 5 system operation mode 5.1 overview the chip is featured with low power consumption by switching around four different modes as following. z high-speed mode z low-speed mode z power-down mode (sleep mode) z green mode power down mode (sleep mode) slow mode green mode normal mode clkmd = 1 clkmd = 0 p0, p1 wake-up function active. usb bus. external reset circuit active. cpum1, cpum0 = 01. cpum1, cpum0 = 10. p0, p1 wake-up function active. t0 timer time out. usb bus. external reset circuit active. p0, p1 wake-up function active. t0 timer time out. usb bus. external reset circuit active. system mode switching diagram operating mode description mode normal slow green power down (sleep) remark hosc running by stphx by stphx stop ilrc running running running stop cpu instruction executi ng executing stop stop t0 timer *active *active *active inactive * active if t0enb=1 t1 timer *active *active inactive inactive * active if t1enb=1 tc0 timer *active *active inactive inactive * active if tc0enb=1 tc1 timer *active *active inactive inactive * active if tc1enb=1 usb running inactive inactive inactive * active if usbe=1 watchdog timer by watch_dog code option by watch_dog code option by watch_dog code option by watch_dog code option refer to code option description internal interrupt all active all active t0 all inactive external interrupt all active all active all active all inactive wakeup source - - p0, p1, t0, reset p0, p1, reset z hosc: high clock (fosc = 12mhz) z ilrc: internal low clock (12khz rc oscillator)
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 59 version 1.1 5.2 system mode switching example ? example: switch normal/slow mode to power down (sleep) mode. b0bset fcpum0 ; set cpum0 = 1. ? note: during the sleep, only the wakeup pin and reset can wakeup the system back to the normal mode. ? example: switch normal mode to slow mode. b0bset fclkmd ;to set clkmd = 1, change the system into slow mode b0bset fstphx ;to stop external high -speed oscillator for power saving. ? example: switch slow mode to normal mode ( the external high-speed oscillator is still running). b0bclr fclkmd ;to set clkmd = 0 example: switch slow mode to normal mode (the external high-speed oscillator stops). if external high clock stop and program want to switch back normal mode. it is necessary to delay at least 10ms for external clock stable. b0bclr fstphx ; turn on the external high-speed oscillator. mov a, #10 ; internal rc=12khz (typical) will delay b0mov z, a @@: decms z ; 0.33ms x 30 ~ 10ms for external clock stable jmp @b ; b0bclr fclkmd ; change the system back to the normal mode example: switch normal/slow mode to green mode. b0bset fcpum1 ; set cpum1 = 1. ? note: if t0 timer wakeup function is disabled in the green mode, only the wakeup pin and reset pin can wakeup the system backs to the previous operation mode.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 60 version 1.1 example: switch normal/slow mode to green mode and enable t0 wake-up function. ; set t0 timer wakeup function. b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0enb ; to disable t0 timer mov a,#20h ; b0mov t0m,a ; to set t0 clock = fcpu / 64 mov a,#74h b0mov t0c,a ; to set t0c initial val ue = 74h (to set t0 interval = 10 ms) b0bclr ft0ien ; to disable t0 interrupt service b0bclr ft0irq ; to clear t0 interrupt request b0bset ft0enb ; to enable t0 timer ; go into green mode b0bclr fcpum0 ;to set cpumx = 10 b0bset fcpum1 ? note: during the green mode with t0 wake-up function, the wakeup pin and t0 wakeup the system back to the last mode. t0 wake-up period is controlled by program.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 61 version 1.1 5.3 wakeup 5.3.1 overview under power down mode (sleep mode) or green mode, progra m doesn?t execute. the wakeup trigger can wake the system up to normal mode or slow mode. the wakeup tri gger sources are external trigger (p0, p1 level change), internal trigger (t0 timer overflow) and usb bus toggle. z power down mode is waked up to normal mode. the wakeup trigger is only external trigger (p0, p1 level change and usb bus toggle) z green mode is waked up to last mode (normal mode or slow mode). the wakeup triggers are external trigger (p0, p1 level change), internal trigger (t0 timer overflow) and usb bus toggle. 5.3.2 wakeup time when the system is in power down mo de (sleep mode), the high clock oscilla tor stops. when wake d up from power down mode, mcu waits for 16384 external 6mhz clocks as the wakeup time to stable the oscillator circuit. after the wakeup time, the system goes into the normal mode. ? note: wakeup from green mode is no wakeup time because the clock doesn?t stop in green mode. the value of the wakeup time is as the following. ?16m_x?tal/12m_x?tal/6m_x?tal? mode: the wakeup time = 1/fosc * 16384 (sec) + high clock start-up time ? note: the high clock start-up time is depended on the vdd and oscillator type of high clock. example: in 16m_x?tal/12m_x?tal/6m_x?tal mode and powe r down mode (sleep mode), the system is waked up. after the wakeup time, the system goes into normal mode. the wakeup time is as the following. the wakeup time = 1/6mhz * 16384 = 2.72 ms the total wakeup time = 2.72 ms + oscillator start-up time
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 62 version 1.1 6 interrupt 6.1 overview this mcu provides 15 interrupt sources, including 11 in ternal interrupt (t0/t1/tc0/t c1/tc2/usb/sio/msp/uart/ad/ io wakeup) and 4 external interrupt (int 0/int1/p0/p1). the external interrupt ca n wakeup the chip while the system is switched from power down mode to high-speed normal mode. once interrupt service is executed, the gie bit in stkp register will clear to ?0? for stopping other interrupt request. on the contrast, when interrupt service exits, the gie bit wil l set to ?1? to accept the next interrupts? request. all of t he interrupt request signals ar e stored in intrq register. ? note: the gie bit must enable during all interrupt operation.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 63 version 1.1 6.2 inten interrupt enable register inten is the interrupt request control register including one internal interrupts, one exte rnal interrupts enable control bits. one of the register to be set ?1? is to enable the interrupt request function. once of the interrupt occur, the stack is incremented and program jump to org 8 to execute interrupt service routines. t he program exits the interrupt service routine when the returning interrupt service routine instruction (reti) is executed. 0c7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten1 p1ien p0ien mspien utrxien u ttxien tc2ien tc1ien tc0ien read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 p1ien: p1 i/o level change interrupt control bit. 0 = disable p1 i/o level change interrupt function. 1 = enable p1 i/o level change interrupt function. bit 6 p0ien: p0 i/o level change interrupt control bit. 0 = disable p0 i/o level change interrupt function. 1 = enable p0 i/o level change interrupt function. bit 5 mspien : msp function interrupt control bit. 0 = disable msp interrupt function. 1 = enable msp interrupt function. bit 4 utrxien: uart rx function interrupt control bit. 0 = disable uart rx interrupt function. 1 = enable uart rx interrupt function. bit 3 uttxien: uart tx function interrupt control bit. 0 = disable uart tx interrupt function. 1 = enable uart tx interrupt function. bit 2 tc2ien: tc2 timer function interrupt control bit. 0 = disable tc2 interrupt function. 1 = enable tc2 interrupt function. bit 1 tc1ien: tc1 timer interrupt control bit. 0 = disable tc1 interrupt function. 1 = enable tc1 interrupt function. bit 0 tc0ien: tc0 timer interrupt control bit. 0 = disable tc0 interrupt function. 1 = enable tc0 interrupt function. 0c9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 inten adcien usbien t1ien t0ien si oien wakeien p01ien p00ien read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 adcien: adc interrupt control bit. 0 = disable adc interrupt function. 1 = enable adc interrupt function. bit 6 usbien: usb interrupt control bit. 0 = disable usb interrupt function. 1 = enable usb interrupt function.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 64 version 1.1 bit 5 t1ien: t1 timer interrupt control bit. 0 = disable t1 interrupt function. 1 = enable t1 interrupt function. bit 4 t0ien: t0 timer interrupt control bit. 0 = disable t0 interrupt function. 1 = enable t0 interrupt function. bit 3 sioien: sio interrupt control bit. 0 = disable sio interrupt function. 1 = enable sio interrupt function. bit 2 wakeien: i/o port0 & port 1 wakeup interrupt control bit. 0 = disable wakeup interrupt function. 1 = enable wakeup interrupt function. bit 1 p01ien: external p0.1 interrupt (int1) control bit. 0 = disable int1 interrupt function. 1 = enable int1 interrupt function. bit 0 p00ien: external p0.0 interrupt (int0) control bit. 0 = disable int0 interrupt function. 1 = enable int0 interrupt function.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 65 version 1.1 6.3 intrq interrupt request register intrq is the interrupt request flag register. the register incl udes all interrupt request indication flags. each one of the interrupt requests occurs; the bit of the intrq register would be set ?1?. the intrq value needs to be clear by programming after detecting the flag. in the interrupt vect or of program, users know the any interrupt requests occurring by the register and do the routi ne corresponding of the interrupt request. 0c6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq1 p1irq p0irq mspirq utrxirq uttxirq tc2irq tc1irq tc0irq read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 p1irq: p1 i/o level change interrupt request flag. 0 = none p1 i/o level change interrupt request. 1 = p1 i/o level change interrupt request. bit 6 p0irq: p0 i/o level change interrupt request flag. 0 = none p0 i/o level change interrupt request. 1 = p0 i/o level change interrupt request. bit 5 mspirq : msp function interrupt request flag. 0 = none msp interrupt request. 1 = msp interrupt request. bit 4 utrxirq: uart rx function interrupt request flag. 0 = none uart rx interrupt request. 1 = uart rx interrupt request. bit 3 uttxirq: uart tx function interrupt request flag. 0 = none uart tx interrupt request. 1 = uart tx interrupt request. bit 2 tc2irq: tc2 timer function interrupt request flag. 0 = none tc2 interrupt request. 1 = t0 interrupt request. bit 1 tc1irq: tc1 timer interrupt request flag. 0 = none tc1 interrupt request. 1 = t0 interrupt request. bit 0 tc0irq: tc0 timer interrupt request flag. 0 = none tc0 interrupt request. 1 = t0 interrupt request. 0c8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 intrq adcirq usbirq t1irq t0irq si oirq wakeirq p01irq p00irq read/write rw r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 adcirq: adc interrupt request flag. 0 = none adc interrupt request. 1 = adc interrupt request. bit 6 usbirq: usb interrupt request flag. 0 = none usb interrupt request. 1 = usb interrupt request.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 66 version 1.1 bit 5 t1irq: t1 timer interrupt request flag. 0 = none t1 interrupt request. 1 = t1 interrupt request. bit 4 t0irq: t0 timer interrupt request flag. 0 = none t0 interrupt request. 1 = t0 interrupt request. bit 3 sioirq: sio interrupt request flag. 0 = none sio interrupt request. 1 = sio interrupt request. bit 2 wakeirq: i/o port0 & port1 wakeup interrupt request flag. 0 = none wakeup interrupt request. 1 = wakeup interrupt request. bit 1 p01irq: external p0.1 interrupt (int1) request flag. 0 = none int0 interrupt request. 1 = int0 interrupt request. bit 0 p00irq: external p0.0 interrupt (int0) request flag. 0 = none int0 interrupt request. 1 = int0 interrupt request. 6.4 gie global interrupt operation gie is the global interrupt control bit. all interrupts start wo rk after the gie = 1 it is necessary for interrupt service request. one of the interrupt requests occurs, and the program co unter (pc) points to the interrupt vector (org 8) and the stack add 1 level. 0dfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 stkp gie - - - - stkpb2 stkpb1 stkpb0 read/write r/w - - - - r/w r/w r/w after reset 0 - - - - 1 1 1 bit 7 gie: global interrupt control bit. 0 = disable global interrupt. 1 = enable global interrupt. example: set global interrupt control bit (gie). b0bset fgie ; enable gie ? note: the gie bit must enable during all interrupt operation. 6.5 push, pop routine when any interrupt occurs, system will jump to org 8 and execute interrupt service routine. it is necessary to save acc, pflag data. the chip includes ?pus h?, ?pop? for in/out interrupt service r outine. the two instructions save and load acc , pflag data into buffers and avoid main routine erro r after interrupt service routine finishing. ? note: ?push?, ?pop? instructions save and load a cc/pflag without (nt0, npd). push/pop buffer is an unique buffer and only one level.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 67 version 1.1 ? example: store acc and paflg data by push, po p instructions when interrupt service routine executed. org 0 jmp start org 8 jmp int_service org 10h start: ? int_service: push ; save acc and pflag to buffers. ? ? pop ; load acc and pflag from buffers. reti ; exit interrupt service vector ? endp
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 68 version 1.1 6.6 int0 (p0.0) & int1 (p0.1) interrupt operation when the int0/int1 trigger oc curs, the p00irq/p01irq will be set to ?1? no matter the p00ien/p01ien is enable or disable. if the p00ien/p01ien = 1 and the trigger event p00irq/p01irq is also set to be ?1?. as the result, the system will execute the interrupt vector (org 8). if the p00ien/p01ien = 0 and the trigger event p00irq/p01irq is still set to be ?1?. moreover, t he system won?t execute interrupt vector even when the p00irq/p01irq is set to be ?1?. users need to be cautious with the opera tion under multi-interrupt situation. if the interrupt trigger direction is identical with wake-u p trigger direction, the int0/int1 interrupt request flag (int0irq/int1irq) is latched while system wake-up from power down mode or green mode by p0.0 wake-up trigger. system inserts to interrupt vector (org 8) after wake-up immediately. ? note: int0 interrupt request can be latched by p0.0 wake-up trigger. ? note: int1 interrupt request can be latched by p0.1 wake-up trigger. ? note: the interrupt trigger direction of p0 .0/p0.1 is control by pedge register. 0bfh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pedge p01g1 p01g0 p00g1 p00g0 read/write r/w r/w r/w r/w after reset 1 0 1 0 bit[3:2] p01g[1:0]: p0.1 interrupt trigger edge control bits. 00 = reserved. 01 = rising edge. 10 = falling edge. 11 = rising/falling bi-direction (level change trigger). bit[1:0] p00g[1:0]: p0.0 interrupt trigger edge control bits. 00 = reserved. 01 = rising edge. 10 = falling edge. 11 = rising/falling bi-direction (level change trigger). example: setup int0 interrupt request and bi-direction edge trigger. mov a, #03h b0mov pedge, a ; set int0 interr upt trigger as bi-direction edge. b0bset fp00ien ; enable int0 interrupt service b0bclr fp00irq ; clear int0 interrupt request flag b0bset fgie ; enable gie
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 69 version 1.1 example: int0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fp00irq ; check p00irq jmp exit_int ; p00irq = 0, exit interrupt vector b0bclr fp00irq ; reset p00irq ? ; int0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 70 version 1.1 6.7 t0 interrupt operation when the t0c counter occurs overflow, the t0irq will be se t to ?1? however the t0ien is enable or disable. if the t0ien = 1, the trigger event will make the t0irq to be ?1? a nd the system enter interrupt vector. if the t0ien = 0, the trigger event will make the t0irq to be ?1? but the system will not enter interr upt vector. users need to care for the operation under multi-interrupt situation. ? example: t0 interrupt request setup. b0bclr ft0ien ; disable t0 interrupt service b0bclr ft0enb ; disable t0 timer mov a, #20h ; b0mov t0m, a ; set t0 clock = fcpu / 64 mov a, #74h ; set t0c initial value = 74h b0mov t0c, a ; set t0 interval = 10 ms b0bset ft0ien ; enable t0 interrupt service b0bclr ft0irq ; clear t0 interrupt request flag b0bset ft0enb ; enable t0 timer b0bset fgie ; enable gie example: t0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ft0irq ; check t0irq jmp exit_int ; t0irq = 0, exit interrupt vector b0bclr ft0irq ; reset t0irq mov a, #74h b0mov t0c, a ; reset t0c. ? ; t0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 71 version 1.1 6.8 t1 interrupt operation when the t1c counter overflows, the t1irq will be set to ?1? no matter the t1ien is enable or disable. if the t1ien and the trigger event t1irq is set to be ?1?. as the result, the system will execute the inte rrupt vector. if the t1ien = 0, the trigger event t1irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the t1ien is set to be ?1?. users need to be cautious with the operation under multi-interrupt situation. ? example: t1 interrupt request setup. b0bclr ft1ien ; disable t1 interrupt service b0bclr ft1enb ; disable t1 timer mov a, #00h ; b0mov t1m, a ; set t1 clock = fcpu / 256 mov a, #0e5h ; set t1cl initial value = e5h b0mov t1cl, a mov a, #48h ; set t1ch initial value = 48h b0mov t1ch, a ; set t1 interval = 1s b0bset ft1ien ; enable t1 interrupt service b0bclr ft1irq ; clear t1 interrupt request flag b0bset ft1enb ; enable t1 timer b0bset fgie ; enable gie example: t1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ft1irq ; check t1irq jmp exit_int ; t1irq = 0, exit interrupt vector b0bclr ft1irq ; reset t1irq mov a, #0e5h b0mov t1cl, a ; reset t1cl. mov a, #48h b0mov t1ch, a ; reset t1ch. ? ; t1 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 72 version 1.1 6.9 tc0 interrupt operation when the tc0c counter overflows, the tc0irq will be set to ?1? no matter the tc0ien is enable or disable. if the tc0ien and the trigger event tc0irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc0ien = 0, the trigger event tc0irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc0ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc0 interrupt request setup. b0bclr ftc0ien ; disable tc0 interrupt service b0bclr ftc0enb ; disable tc0 timer mov a, #20h ; b0mov tc0m, a ; set tc0 clock = fcpu / 64 mov a, #74h ; set tc0c initial value = 74h b0mov tc0c, a ; set tc0 interval = 10 ms b0bset ftc0ien ; enable tc0 interrupt service b0bclr ftc0irq ; clear tc0 interrupt request flag b0bset ftc0enb ; enable tc0 timer b0bset fgie ; enable gie ? example: tc0 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc0irq ; check tc0irq jmp exit_int ; tc0irq = 0, exit interrupt vector b0bclr ftc0irq ; reset tc0irq mov a, #74h b0mov tc0c, a ; reset tc0c. ? ; tc0 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 73 version 1.1 6.10 tc1 interrupt operation when the tc1c counter overflows, the tc1irq will be set to ?1? no matter the tc1ien is enable or disable. if the tc1ien and the trigger event tc1irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc1ien = 0, the trigger event tc1irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc1ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc1 interrupt request setup. b0bclr ftc1ien ; disable tc1 interrupt service b0bclr ftc1enb ; disable tc1 timer mov a, #20h ; b0mov tc1m, a ; set tc1 clock = fcpu / 64 mov a, #74h ; set tc1c initial value = 74h b0mov tc1c, a ; set tc1 interval = 10 ms b0bset ftc1ien ; enable tc1 interrupt service b0bclr ftc1irq ; clear tc1 interrupt request flag b0bset ftc1enb ; enable tc1 timer b0bset fgie ; enable gie ? example: tc1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc1irq ; check tc1irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc1irq ; reset tc1irq mov a, #74h b0mov tc1c, a ; reset tc1c. ? ; tc1 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 74 version 1.1 6.11 tc2 interrupt operation when the tc2c counter overflows, the tc2irq will be set to ?1? no matter the tc2ien is enable or disable. if the tc2ien and the trigger event tc2irq is set to be ?1?. as t he result, the system will execute the interrupt vector. if the tc2ien = 0, the trigger event tc2irq is still set to be ?1?. moreover, the system won?t execute interrupt vector even when the tc2ien is set to be ?1?. users need to be cautio us with the operation under multi-interrupt situation. ? example: tc1 interrupt request setup. b0bclr ftc2ien ; disable tc2 interrupt service b0bclr ftc2enb ; disable tc2 timer mov a, #20h ; b0mov tc2m, a ; set tc2 clock = fcpu / 64 mov a, #74h ; set tc2c initial value = 74h b0mov tc2c, a ; set tc2 interval = 10 ms b0bset ftc2ien ; enable tc2 interrupt service b0bclr ftc2irq ; clear tc2 interrupt request flag b0bset ftc2enb ; enable tc2 timer b0bset fgie ; enable gie ? example: tc1 interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 ftc2irq ; check tc2irq jmp exit_int ; tc1irq = 0, exit interrupt vector b0bclr ftc2irq ; reset tc2irq mov a, #74h b0mov tc1c, a ; reset tc2c. ? ; tc2 interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 75 version 1.1 6.12 usb interrupt operation when the usb process finished, the usbirq will be set to ?1? no matter the usbien is enable or disable. if the usbien and the trigger event usbirq is set to be ?1?. as the result, the system will exec ute the interrupt vector. if the usbien = 0, the trigger event usbirq is still set to be ?1?. moreover, the system won?t execute interrupt vector. users need to be cautious with the opera tion under multi-interrupt situation. ? example: usb interrupt request setup. b0bclr fusbien ; disable usb interrupt service b0bclr fusbirq ; clear usb interrupt request flag b0bset fusbien ; enable usb interrupt service ? ; usb initializes. ? ; usb operation. b0bset fgie ; enable gie example: usb interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: push ; push routine to save acc and pflag to buffers. b0bts1 fusbirq ; check usbirq jmp exit_int ; usbirq = 0, exit interrupt vector b0bclr fusbirq ; reset usbirq ? ; usb interrupt service routine ? exit_int: pop ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 76 version 1.1 6.13 wakeup interrupt operation when the i/o port 1 or i/o port 0 wakeup the mcu from the sleep mode, the wakeirq will be set to ?1? no matter the wakeien is enable or disable. if the wakeien and the trigger event wakeirq is set to be ?1?. as the result, the system will execute the interr upt vector. if the wakeien = 0, the trigger event wakeir q is still set to be ?1?. moreover, the system won?t execute inte rrupt vector. users need to be cautious with the operation under multi-interrupt situation. ? example: wake interrupt request setup. b0bclr fwakeien ; disable wake interrupt service b0bclr fwakeirq ; clear wake interrupt request flag b0bset fwakeien ; enable wake interrupt service ? ; pin wakeup initialize. ? ; pin wakeup operation. b0bset fgie ; enable gie example: wake interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: push ; push routine to save acc and pflag to buffers. b0bts1 fwakeirq ; check wakeirq jmp exit_int ; wakeirq = 0, exit interrupt vector b0bclr fwakeirq ; reset wakeirq ? ; wake interrupt service routine ? exit_int: pop ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 77 version 1.1 6.14 sio interrupt operation when the sio converting successfully, t he sioirq will be set to ?1? no matter t he sioien is enable or disable. if the sioien and the trigger event sioirq is set to be ?1?. as the result, the system will execute the interrupt vector. if the sioien = 0, the trigger event sioirq is still set to be ?1?. moreover, t he system won?t execute interrupt vector even when the sioien is set to be ?1?. users need to be cauti ous with the operation under multi-interrupt situation. ? example: sio interrupt request setup. b0bset fsioien ; enable sio interrupt service b0bclr fsioirq ; clear sio interrupt request flag b0bset fgie ; enable gie ? example: sio interrupt service routine. org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. b0bts1 fsioirq ; check sioirq jmp exit_int ; sioirq = 0, exit interrupt vector b0bclr fsioirq ; reset sioirq ? ; sio interrupt service routine ? exit_int: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 78 version 1.1 6.15 multi-interrupt operation under certain condition, the software designer uses more than one interrupt requests. processing multi-interrupt request requires setting the priority of the interrupt requests. the irq flags of interrupts are controlled by the interrupt event. nevertheless, the irq flag ?1? doesn?t mean the syst em will execute the interrupt vector. in addition, which means the irq flags can be set ?1? by the events without enable the interrupt. once the event occurs, the irq will be logic ?1?. the irq and its trigger event relationship is as the below table. interrupt name trigger event description p00irq p0.0 trigger controlled by pedge t0irq t0c overflow t1irq t1c overflow usbirq usb process finished waekirq i/o port0 & port1 wakeup mcu sioirq sio process finished for multi-interrupt conditions, two things need to be taking care of. one is to set the priority for these interrupt requests. two is using ien and irq flags to decide which interrupt to be executed. users have to check interrupt control bit and interrupt request flag in interrupt routine. ? example: check the interrupt request under multi-interrupt operation org 8 ; interrupt vector jmp int_service int_service: ? ; push routine to save acc and pflag to buffers. intp00chk: ; check int0 interrupt request b0bts1 fp00ien ; check p00ien jmp intt0chk ; jump check to next interrupt b0bts0 fp00irq ; check p00irq jmp intp00 intt0chk: ; check t0 interrupt request b0bts1 ft0ien ; check t0ien jmp intt1chk ; jump check to next interrupt b0bts0 ft0irq ; check t0irq jmp intt0 ; jump to t0 interrupt service routine intt1chk: ; check t1 interrupt request b0bts1 ft1ien ; check t1ien jmp inttc1chk ; jump check to next interrupt b0bts0 ft1irq ; check t1irq jmp intt1 ; jump to t1 interrupt service routine intusbchk: ; check usb interrupt request b0bts1 fusbien ; check usbien jmp intwakechk ; jump check to next interrupt b0bts0 fusbirq ; check usbirq jmp intusb ; jump to usb interrupt service routine intwakechk: ; check usb interrupt request b0bts1 fwakeien ; check wakeien jmp intsiochk ; jump check to next interrupt b0bts0 fwakeirq ; check wakeirq jmp intwakeup ; jump to wakeu p interrupt service routine intsiochk: ; check sio interrupt request b0bts1 fsioien ; check sioien jmp int_exit ; jump check to next interrupt b0bts0 fsioirq ; check sioirq jmp intsio ; jump to sio interrupt service routine int_exit: ? ; pop routine to load acc and pflag from buffers. reti ; exit interrupt vector
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 79 version 1.1 7 i/o port 7.1 i/o port mode the port direction is programmed by pnm register. a ll i/o ports can select input or output direction. 0b8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0m p07m p06m p05m p04m p03m p02m p01m p00m read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0c1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1m p17m p16m p15m p14m p13m p12m p11m p10m read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0c2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2m p27m p26m p25m p24m p23m p22m p21m p20m read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0c4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4m p47m p46m p45m p44m p43m p42m p41m p40m read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0c5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5m - - p55m p54m p53m p52m p51m p50m read/write - - r/w r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 bit[7:0] pnm[7:0]: pn mode control bits. (n = 0~3). 0 = pn is input mode. 1 = pn is output mode. ? note: 1. users can program them by bit c ontrol instructions (b0bset, b0bclr). ? example: i/o mode selecting clr p0m ; set all ports to be input mode. clr p1m clr p5m mov a, #0ffh ; set all ports to be output mode. b0mov p0m, a b0mov p1m, a b0mov p5m, a
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 80 version 1.1 b0bclr p1m.2 ; set p1.2 to be input mode. b0bset p1m.2 ; set p1.2 to be output mode.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 81 version 1.1 7.2 i/o pull up register 0e0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0ur p07r p06r p05r p00r p03r p02r p01r p00r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 0e1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1ur p17r p16r p15r p16r p13r p12r p11r p10r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 0e2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2ur p27r p26r p25r p24r p23r p22r p21r p20r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 0e4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4ur p47r p46r p45r p44r p43r p42r p41r p40r read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 0e5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5ur - - p55r p54r p53r p52r p51r p50r read/write - - w w w w w w after reset - - 0 0 0 0 0 0 ? note: p0.4 is input only pin with pull-up resister. ? example: i/o pull up register mov a, #0ffh ; enable port0, 1, 5 pull-up register, b0mov p0ur, a ; b0mov p1ur, a b0mov p5ur, a
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 7.3 i/o open-drain register p1.0/p1.1/p0.6/p0.5 is built-in open-drain function. p1.0/p1.1/p0.6/p0.5 must be set as output mode when enable p1.0/p1.1/p0.6/p0.5 open-drain function. open- drain external circuit is as following. u mcu2 u vcc open-drain pin open-drain pin mcu1 pull-up resistor the pull-up resistor is necessary. open-drain output high is driven by pull-up resistor. output low is sunken by mcu?s pin. 0e9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1oc - - - - p06oc p05oc p11oc p10oc read/write - - - - w w w w after reset - - - - 0 0 0 0 bit [3:2] p0noc: port 0 open-drain control bit 0 = disable open-drain mode 1 = enable open-drain mode bit [1:0] p1noc: port 1 open-drain control bit 0 = disable open-drain mode 1 = enable open-drain mode ? example: enable p1.0 to open-drain mode and output high. b0bset p1.0 ; set p1.0 buffer high. b0bset p10m ; enable p1.0 output mode. mov a, #01h ; enable p1.0 open-drain function. b0mov p1oc, a ? note: p1oc is write only register. setting p10oc must be used ?mov? instructions. ? example: disable p1.0 to open-drain mode and output low. mov a, #0 ; disable p1.0 open-drain function. b0mov p1oc, a ? note: after disable p1.0 open-drain function, p1.0 mode returns to last i/o mode. sonix technology co., ltd page 82 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 83 version 1.1 7.4 i/o port data register 0d0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p0 p07 p06 p05 p04 p03 p02 p01 p00 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0d1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1 p17 p16 p15 p14 p13 p12 p11 p10 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0d2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p2 p27 p26 p25 p24 p23 p22 p21 p20 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0d4h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4 p47 p46 p45 p44 p43 p42 p41 p40 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0d5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p5 - - p55 p54 p53 p52 p51 p50 read/write - - r/w r/w r/w r/w r/w r/w after reset - - 0 0 0 0 0 0 ? example: read data from input port. b0mov a, p0 ; read data from port 0 b0mov a, p1 ; read data from port 1 b0mov a, p5 ; read data from port 5 ? example: write data to output port. mov a, #0ffh ; write data ffh to all port. b0mov p0, a b0mov p1, a b0mov p5, a ? example: write one bit data to output port. b0bset p1.3 ; set p1.3 and p5.3 to be ?1?. b0bset p5.3 b0bclr p1.3 ; set p1.3 and p5.3 to be ?0?. b0bclr p5.3
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 84 version 1.1 7.5 i/o port1 wakeup control register 0c0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p1w p17w p16w p15w p14w p13w p12w p11w p10w read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] p1nw: port 1 wakeup function control bit. 0 = disable port 1 wakeup function. 1 = enable port 1 wakeup function.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 85 version 1.1 8 timers 8.1 watchdog timer the watchdog timer (wdt) is a binary up counter designed for monitoring program execution. if the program goes into the unknown status by noise interferen ce, wdt overflow signal raises and resets mcu. watchdog clock controlled by code option and the clock source is in ternal low-speed oscillator (12khz). watchdog overflow time = 8192 / inte rnal low-speed oscillator (sec). vdd internal low rc freq. code option ? slow mode setting watchdog overflow time 5v 12khz flosc/2 341ms 5v 12khz flosc/4 682ms ? note: if watchdog is ?always_on? mode, it keeps running event under power down mode or green mode. watchdog clear is controlled by wdtr register. moving 0x5a data into wdtr is to reset watchdog timer. 0cch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 wdtr wdtr7 wdtr6 wdtr5 wdtr4 wdtr3 wdtr2 wdtr1 wdtr0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: mov a,#5ah ; clear the watchdog timer. b0mov wdtr,a ? call sub1 call sub2 ? ? ? jmp main
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 86 version 1.1 watchdog timer application note is as following. z before clearing watchdog timer, check i/o status and check ram contents c an improve system error. z don?t clear watchdog timer in interrupt vector and interrupt service routine. that can improve main routine fail. z clearing watchdog timer program is only at one part of the program. this way is the best structure to enhance the watchdog timer function. ? example: an operation of watchdog timer is as following. to clear the watchdog timer counter in the top of the main routine of the program. main: ? ; check i/o. ? ; check ram err: jmp $ ; i/o or ram error. program jump here and don?t ; clear watchdog. wait watchdog timer overflow to reset ic. correct: ; i/o and ram are correct. clear watchdog timer and ; execute program. mov a,#5ah ; clear the watchdog timer. b0mov wdtr,a ? call sub1 call sub2 ? ? ? jmp main
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.2 timer 0 (t0) 8.2.1 overview the t0 is an 8-bit binary up timer and event counter. if t0 ti mer occurs an overflow (from ffh to 00h), it will continue counting and issue a time-out signal to trigger t0 interrupt to request interrupt service. the main purpose of the t0 timer is as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) green mode wakeup function: t0 can be green mode wake -up time as t0enb = 1. system will be wake-up by t0 time out. fcpu t0 rate (fcpu/2~fcpu/256) t0enb cpum0,1 t0c 8-bit binary up counting counter t0 time out load internal data bus 8.2.2 t0m mode register 0d8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0m t0enb t0rate2 t0rate1 t0rate0 - - - read/write r/w r/w r/w r/w - - - after reset 0 0 0 0 - - - bit 7 t0enb: t0 counter control bit. 0 = disable t0 timer. 1 = enable t0 timer. bit [6:4] t0rate[2:0]: t0 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. sonix technology co., ltd page 87 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 88 version 1.1 8.2.3 t0c counting register t0c is an 8-bit counter register for t0 interval time control. 0d9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t0c t0c7 t0c6 t0c5 t0c4 t0c3 t0c2 t0c1 t0c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t0c initial value is as following. t0c initial value = 256 - (t0 interrupt interval time * input clock) example: to set 1ms interval time for t0 interrupt . high clock is 12mhz. fcpu=fosc/2. select t0rate=010 (fcpu/64). t0c initial value = 256 - (t0 interrupt interval time * input clock) = 256 - (1ms * 6mhz / 1 / 64) = 256 - (10 -3 * 6 * 10 6 / 1 / 64) = 162 = a2h the basic timer table interval time of t0. high speed mode (fcpu = 12mhz / 2) t0rate t0clock max overflow interval one step = max/256 000 fcpu/256 10.923 ms 42.67 us 001 fcpu/128 5.461 ms 21.33 us 010 fcpu/64 2.731 ms 10.67 us 011 fcpu/32 1.365 ms 5.33 us 100 fcpu/16 0.683 ms 2.67 us 101 fcpu/8 0.341 ms 1.33 us 110 fcpu/4 0.171 ms 0.67 us 111 fcpu/2 0.085 ms 0.33 us
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 89 version 1.1 8.2.4 t0 timer operation sequence t0 timer operation sequence of setup t0 timer is as following. ) stop t0 timer counting, disable t0 interrupt function and clear t0 interrupt request flag. b0bclr ft0enb ; t0 timer. b0bclr ft0ien ; t0 interrupt function is disabled. b0bclr ft0irq ; t0 interrupt request flag is cleared. ) set t0 timer rate. mov a, #0xxx0000b ;the t0 rate control bi ts exist in bit4~bit6 of t0m. the ; value is from x000xxxxb~x111xxxxb. b0mov t0m,a ; t0 timer is disabled. ) set t0 interrupt interval time. mov a,#7fh b0mov t0c,a ; set t0c value. ) set t0 timer function mode. b0bset ft0ien ; enable t0 interrupt function. ) enable t0 timer. b0bset ft0enb ; enable t0 timer.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.3 timer t1 (t1) 8.3.1 overview the t1 is a 16-bit binary up timer and event counter. if t1 timer occurs an overflow (from ffffh to 0000h), it will continue counting and issue a time-out signal to trig ger t1 interrupt to request interrupt service. the main purpose of the t1 timer is as following. ) 16-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) green mode wakeup function: t1 can be green mode wake -up time as t1enb = 1. system will be wake-up by t1 time out. fcpu t1 rate (fcpu/2~fcpu/256) t1enb cpum0,1 t1c 16-bit binary up counting counter t1 time out load internal data bus 8.3.2 t1m mode register 0dah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1m t1enb t1rate2 t1rate1 t1rate0 - - - read/write r/w r/w r/w r/w - - - after reset 0 0 0 0 - - - bit 7 t1enb: t1 counter control bit. 0 = disable t1 timer. 1 = enable t1 timer. bit [6:4] t1rate[2:0]: t1 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. sonix technology co., ltd page 90 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 91 version 1.1 8.3.3 t1c counting register t1cl with t1ch is an 16-bit counter register for t1 interval time control. 0dbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1cl t1c7 t1c6 t1c5 t1c4 t1c3 t1c2 t1c1 t1c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0dch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 t1ch t1c15 t1c14 t1c13 t1c12 t1c11 t1c10 t1c9 t1c8 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of t1c initial value is as following. t1c initial value = 65536 - (t1 interrupt interval time * input clock) example: to set 1ms interval time for t1 interrupt . high clock is 12mhz. fcpu=fosc/2. select t1rate=001 (fcpu/128). t1c initial value = 65536 - (t1 interrupt interval time * input clock) = 65536 - (1s * 12mhz / 2 / 128) = 65536 - (10 * 6 * 10 6 / 1 / 128) = 18661 = 48e5h the basic timer table interval time of t1. high speed mode (fcpu = 12mhz / 2) t1rate t1clock max overflow interval one step = max/256 000 fcpu/256 2.796 s 42.67 us 001 fcpu/128 1.398 s 21.33 us 010 fcpu/64 699.051 ms 10.67 us 011 fcpu/32 349.525 ms 5.33 us 100 fcpu/16 174.763 ms 2.67 us 101 fcpu/8 87.381 ms 1.33 us 110 fcpu/4 43.691 ms 0.67 us 111 fcpu/2 21.845 ms 0.33 us 8.3.4 t1 timer operation sequence t1 timer operation sequence of setup t1 timer is as following. ) stop t1 timer counting, disable t1 interrupt function and clear t1 interrupt request flag. b0bclr ft1enb ; t1 timer. b0bclr ft1ien ; t1 interrupt function is disabled. b0bclr ft1irq ; t1 interrupt request flag is cleared.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 92 version 1.1 ) set t1 timer rate. mov a, #0xxx0000b ;the t1 rate control bi ts exist in bit4~bit6 of t1m. the ; value is from x000xxxxb~x111xxxxb. b0mov t1m,a ; t1 timer is disabled. ) set t1 interrupt interval time. mov a,#0e5h b0mov t1cl,a ; set t1cl value. mov a,#48h b0mov t1ch,a ; set t1ch value. ) set t1 timer function mode. b0bset ft1ien ; enable t1 interrupt function. ) enable t1 timer. b0bset ft1enb ; enable t1 timer.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.4 timer/counter 0 (tc0~tc2) 8.4.1 overview the tcn (n=0, 1, 2) is an 8-bit binary up counting timer with double buffers. tcn has two clock sources including internal clock and external clock for counting a precision time . the internal clock source is from fcpu. the external clock is int0 from p0.0 pin (falling ed ge trigger). using tcnm register selects tcnc?s clock source from internal or external. if tcn timer occurs an overflow, it will continue coun ting and issue a time-out signal to trigger tcn interrupt to request interrupt service. tcn overflow time is 0xff to 0x00 normally. under pwm mode, tcn overflow is decided by pwm cycle controlled by aloadn (n=0, 1, 2) and tcnout bits. the main purposes of the tcn timer are as following. ) 8-bit programmable up counting timer: generates interrupts at specific time intervals based on the selected clock frequency. ) external event counter: counts system ?events? based on falling edge detection of external clock signals at the int0 input pin. ) buzzer output ) pwm output sonix technology co., ltd page 93 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 94 version 1.1 8.4.2 tcnm mode register 088h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0m tc0enb tc0rate2 tc0rate1 tc0rate0 tc0cks aload0 tc0out pwm0out read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 tc0enb: tc0 counter control bit. 0 = disable tc0 timer. 1 = enable tc0 timer. bit [6:4] tc0rate[2:0]: tc0 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. bit 3 tc0cks: tc0 clock source select bit. 0 = internal clock (fcpu or fosc). 1 = external clock from p0.0/int0 pin. bit 2 aload0: auto-reload control bit. only valid when pwm0out = 0. 0 = disable tc0 auto-reload function. 1 = enable tc0 auto-reload function. bit 1 tc0out: tc0 time out toggle signal output control bit. only valid when pwm0out = 0. 0 = disable, p5.3 is i/o function. 1 = enable, p5.3 is output tc0out signal. bit 0 pwm0out: pwm output control bit. 0 = disable pwm output. 1 = enable pwm output. pwm duty controlled by tc0out, aload0 bits. ? note: when tc0cks=1, tc0 became an external event counter and tc0rate is useless. no more p0.0 interrupt request will be raised. (p0.0irq will be always 0). 08bh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1m tc1enb tc1rate2 tc1rate1 tc1rate0 tc1cks aload1 tc1out pwm1out read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 tc1enb: tc1 counter control bit. 0 = disable tc1 timer. 1 = enable tc1 timer. bit [6:4] tc1rate[2:0]: tc1 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. bit 3 tc1cks: tc1 clock source select bit. 0 = internal clock (fcpu or fosc).
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 95 version 1.1 1 = external clock from p0.1/int1 pin. bit 2 aload1: auto-reload control bit. only valid when pwm1out = 0. 0 = disable tc1 auto-reload function. 1 = enable tc1 auto-reload function. bit 1 tc1out: tc1 time out toggle signal output control bit. only valid when pwm1out = 0. 0 = disable, p5.4 is i/o function. 1 = enable, p5.4 is output tc0out signal. bit 0 pwm1out: pwm output control bit. 0 = disable pwm output. 1 = enable pwm output. pwm duty controlled by tc1out, aload1 bits. ? note: when tc1cks=1, tc0 became an external event counter and tc1rate is useless. no more p0.1 interrupt request will be raised. (p0.1irq will be always 0). 08eh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc2m tc2enb tc2rate2 tc2rate1 tc2rate0 tc2cks aload2 tc2out pwm2out read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 tc2enb: tc2 counter control bit. 0 = disable tc2 timer. 1 = enable tc2 timer. bit [6:4] tc2rate[2:0]: tc2 internal clock select bits. 000 = fcpu/256. 001 = fcpu/128. ? 110 = fcpu/4. 111 = fcpu/2. bit 3 tc2cks: tc2 clock source select bit. 0 = internal clock (fcpu or fosc). 1 = external clock from p0.2 pin. bit 2 aload2: auto-reload control bit. only valid when pwm2out = 0. 0 = disable tc2 auto-reload function. 1 = enable tc2 auto-reload function. bit 1 tc2out: tc2 time out toggle signal output control bit. only valid when pwm2out = 0. 0 = disable, p5.5 is i/o function. 1 = enable, p5.5 is output tc2out signal. bit 0 pwm2out: pwm output control bit. 0 = disable pwm output. 1 = enable pwm output. pwm duty controlled by tc2out, aload2 bits.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 96 version 1.1 8.4.3 tcnc counting register tcnc (n = 0, 1, 2) is an 8-bit counter r egister for tcn interval time control. 089h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0c tc0c7 tc0c6 tc0c5 tc0c4 tc0c3 tc0c2 tc0c1 tc0c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 08ch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1c tc1c7 tc1c6 tc1c5 tc1c4 tc1c3 tc1c2 tc1c1 tc1c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 08fh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc2c tc2c7 tc2c6 tc2c5 tc2c4 tc2c3 tc2c2 tc2c1 tc2c0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 the equation of tcnc initial value is as following. tcnc initial value = n - (tcn interrupt interval time * input clock) n is tcn overflow boundary number. tcn timer overflow time has six types (tcn timer, tcn event counter, tcn fcpu clock source, tcn fosc clock source, pwm mode and no pw m mode). these parameters decide tcn overflow time and valid value as follow table. tcncks pwmn aloadn tcnout n tcnc valid value tcnc value binary type remark 0 x x 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 0 256 0x00~0xff 00000000b~11111111b overflow per 256 count 1 0 1 64 0x00~0x3f xx000000b~xx111111b overflow per 64 count 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b overflow per 32 count 0 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b overflow per 16 count 1 - - - 256 0x00~0xff 00000000b~11111111b overflow per 256 count ? example: to set 1ms interval time for tcn interr upt. tcn clock source is fcpu (tcnks=0) and no pwm output (pwmn=0). high clock is internal 6mhz. fcpu=fosc/2. select tcnrate=010 (fcpu/64). tcnc initial value = n - (tcn interrupt interval time * input clock) = 256 - (1ms * 6mhz / 1 / 64) = 256 - (10 -3 * 6 * 10 6 / 1 / 64) = 162 = a2h the basic timer table interval time of tcn. high speed mode (fcpu = 6mhz / 1) tcnrate tcnclock max overflow interval one step = max/256 000 fcpu/256 10.923 ms 42.67 us 001 fcpu/128 5.461 ms 21.33 us 010 fcpu/64 2.731 ms 10.67 us 011 fcpu/32 1.365 ms 5.33 us 100 fcpu/16 0.683 ms 2.67 us 101 fcpu/8 0.341 ms 1.33 us 110 fcpu/4 0.171 ms 0.67 us 111 fcpu/2 0.085 ms 0.33 us
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 97 version 1.1 8.4.4 tcnr auto-load register tcn (n = 0, 1, 2) timer is with auto-load function controlled by aloadn (n = 0, 1, 2) bit of tcnm (n = 0, 1, 2). when tcnc (n = 0, 1, 2) overflow occurring, tcnr (n = 0, 1, 2) value will load to tcnc by system. it is easy to generate an accurate time, and users don?t reset tcnc during interrupt service routine. tcn is double buffer design. if new tcnr value is set by program, the new value is stored in 1 st buffer. until tcn overflow occurs, the new value moves to real tcnr buffer. this way can avoid tcn interval time error and glitch in pwm and buzzer output. ? note: under pwm mode, auto-load is enabled automatically. the aloadn bit is selecting overflow boundary. 08ah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc0r tc0r7 tc0r6 tc0r5 tc0r4 tc0r3 tc0r2 tc0r1 tc0r0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 08dh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc1r tc1r7 tc1r6 tc1r5 tc1r4 tc1r3 tc1r2 tc1r1 tc1r0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 090h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 tc2r tc2r7 tc2r6 tc2r5 tc2r4 tc2r3 tc2r2 tc2r1 tc2r0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the equation of tcnr initial value is as following. tcnr initial value = n - (tcn interrupt interval time * input clock) n is tcn overflow boundary number. tcn timer overflow time has six types (tcn timer, tcn event counter, tcn fcpu clock source, tcn fosc clock source, pwm mode and no pw m mode). these parameters decide tcn overflow time and valid value as follow table. tcncks pwmn aloadn tcnout n tcnr valid value tcnr value binary type 0 x x 256 0x00~0xff 00000000b~11111111b 1 0 0 256 0x00~0xff 00000000b~11111111b 1 0 1 64 0x00~0x3f xx000000b~xx111111b 1 1 0 32 0x00~0x1f xxx00000b~xxx11111b 0 1 1 1 16 0x00~0x0f xxxx0000b~xxxx1111b 1 - - - 256 0x00~0xff 00000000b~11111111b ? example: to set 1ms interval time for tcn interr upt. tcn clock source is fcpu (tcnks=0) and no pwm output (pwmn=0). high clock is internal 6mhz. fcpu=fosc/2. select tcnrate=010 (fcpu/64). tcnr initial value = n - (tcn interrupt interval time * input clock) = 256 - (1ms * 6mhz / 1 / 64) = 256 - (10 -3 * 6 * 10 6 / 1 / 64) = 162 = a2h
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.4.5 tcn clock freque ncy output (buzzer) buzzer output (tcnout) is from tcn timer/counter frequen cy output function. if setting the tc0 clock frequency, the clock signal is output to p5.3 and the p5.3 general purpose i/o function is auto-disable. the tcnout frequency is divided by 2 from tcn interval time. tcnout frequency is 1/2 tcn frequency. the tcn clock has many combinations and easily to make difference frequency. the tcnout frequency waveform is as following. ? example: setup tc0out output from tc0 to tc0out (p5.3). the external high-speed clock is 4mhz. the tc0out frequency is 0.5khz. because the tc0out signal is divided by 2, set the tc0 clock to 1khz. the tc0 clock source is from external o scillator clock. t0c rate is fcpu/ 4. the tc0rate2~tc0rate1 = 110. tc0c = tcnr = 131. mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#131 ; set the auto-reload reference value b0mov tc0c,a b0mov tc0r,a b0bset ftc0out ; enable tc0 output to p5.3 and disable p5.3 i/o function b0bset faload0 ; enable tc0 auto-reload function b0bset ftc0enb ; enable tc0 timer ? note: buzzer output is enable, and ?pwm0out? must be ?0?. sonix technology co., ltd page 98 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 99 version 1.1 8.4.6 tcn timer operation sequence tcn timer operation includes timer interrupt, event counter , tcnout and pwm. the sequence of setup tc0 timer is as following. ) stop tc0 timer counting, disable tc0 interrupt function and clear tc0 interrupt request flag. b0bclr ftc0enb ; tc0 timer, tc0out and pwm stop. b0bclr ftc0ien ; tc0 inte rrupt function is disabled. b0bclr ftc0irq ; tc0 interrupt request flag is cleared. ) set tc0 timer rate. (besides event counter mode.) mov a, #0xxx0000b ;the tc0 rate control bi ts exist in bit4~bit6 of tc0m. the ; value is from x000xxxxb~x111xxxxb. b0mov tc0m,a ; tc0 interr upt function is disabled. ) set tc0 timer clock source. ; select tc0 internal / external clock source. b0bclr ftc0cks ; select tc0 internal clock source. or b0bset ftc0cks ; select tc 0 external clock source. ) set tc0 timer auto-load mode. b0bclr faload0 ; enable tc0 auto reload function. or b0bset faload0 ; disable tc0 auto reload function. ) set tc0 interrupt interval time, tc0out (buzzer) frequency or pwm duty cycle. ; set tc0 interrupt interval time, tc 0out (buzzer) frequency or pwm duty. mov a,#7fh ; tc0c and tc0r value is decided by tc0 mode. b0mov tc0c,a ; set tc0c value. b0mov tc0r,a ; set tc0r value unde r auto reload mode or pwm mode. ; in pwm mode, set pwm cycle. b0bclr faload0 ; aload0, tc0out = 00, pwm cycle boundary is b0bclr ftc0out ; 0~255. or b0bclr faload0 ; aload0, tc0out = 01, pwm cycle boundary is b0bset ftc0out ; 0~63. or b0bset faload0 ; aload0, tc0out = 10, pwm cycle boundary is b0bclr ftc0out ; 0~31. or b0bset faload0 ; aload0, tc0out = 11, pwm cycle boundary is b0bset ftc0out ; 0~15. ) set tc0 timer function mode. b0bset ftc0ien ; enable tc0 interrupt function. or b0bset ftc0out ; enable tc0out (buzzer) function. or b0bset fpwm0out ; enable pwm function. ) enable tc0 timer. b0bset ftc0enb ; enable tc0 timer.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.5 pwmn mode 8.5.1 overview pwm function is generated by tcn timer counter and out put the pwm signal to pwm0out pin (p5.3), pwm1out pin (p5.4) pwm2out pin (p5.5). the 8-bit counter counts modulus 256, 64, 32, 16 controlled by aloadn, tcnout bits. the value of the 8-bit counter (tcnc) is compared to the contents of the reference register (tcnr). when the reference register value (tcnr) is equal to the counter value (tcnc), the pwm output goes low. when the counter reaches zero, the pwm output is forced high. the low-to-high ratio (duty) of the pwmn output is tcnr/256, 64, 32, 16. pwm output can be held at low level by continuously loading the reference register with 00h. under pwm operating, to change the pwm?s duty cycle is to modify the tcnr. ? note: tcn is double buffer design. modifying tcnr to change pwm duty by program, there is no glitch and error duty signal in pwm output waveform. users can change tcnr any time, and the new reload value is loaded to tcnr buffer at tcn overflow. aloadn tcnout pwm duty range tcnc valid value tcnr valid bits value max. pwm frequency (fcpu = 6mhz) remark 0 0 0/256~255/256 0x00~0xff 0x00~0xff 11.719k overflow per 256 count 0 1 0/64~63/64 0x00~0x3f 0x00~0x3f 46.875k overflow per 64 count 1 0 0/32~31/32 0x00~0x1f 0x00~0x1f 93.75k overflow per 32 count 1 1 0/16~15/16 0x00~0x0f 0x00~0x0f 187.5k overflow per 16 count the output duty of pwm is with different tcnr. duty range is from 0/256~255/256. sonix technology co., ltd page 100 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.5.2 tcnirq and pwm duty in pwm mode, the frequency of tcnirq is depended on pwm duty range. from following diagram, the tcnirq frequency is related with pwm duty. sonix technology co., ltd page 101 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 8.5.3 pwm duty with tcnr changing in pwm mode, the system will compare tcnc and tcnr all the time. when tcnc = tcnr pwm high > low tcnc < tcnr pwm low > high in period 2 and period 4, new duty (tcnr) is set. tcn is double buffer de sign. the pwm still keeps the same duty in period 2 and period 4, and the new duty is changed in ne xt period. by the way, sy stem can avoid the pwm not changing or h/l changing twice in the same cycle an d will prevent the unexpected or error operation. sonix technology co., ltd page 102 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 103 version 1.1 8.5.4 pwm program example ? example: setup pwm0 output from tc0 to pwm0out (p5.3). the clock source is internal 12mhz. fcpu = fosc/2 = 6mhz. the duty of pwm is 30/256. the pwm fr equency is about 6khz. the pwm clock source is from external oscillator clock. tc0 rate is fcpu/ 4. the tc0rate2~tc0rate1 = 110. tc0c = tc0r = 30. mov a,#01100000b b0mov tc0m,a ; set the tc0 rate to fcpu/4 mov a,#30 ; set the pwm duty to 30/256 b0mov tc0c,a b0mov tc0r,a b0bclr ftc0out ; set duty range as 0/256~255/256. b0bclr faload0 b0bset fpwm0out ; enable pwm0 output to p5.4 and disable p5.4 i/o function b0bset ftc0enb ; enable tc0 timer ? note: the tcnr is write-only register. don?t pr ocess them using incms, decms instructions. ? example: modify tc0r registers? value. mov a, #30h ; input a number using b0mov instruction. b0mov tc0r, a incms buf0 ; get the new tc0r value from the buf0 buffer defined by nop ; programming. b0mov a, buf0 b0mov tc0r, a ? note: the pwm can work with interrupt request.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 104 version 1.1 9 universal serial bus (usb) 9.1 overview the usb is the answer to connectivity for the pc architectu re. a fast, bi-directional interrupt pipe, low-cost, dynamically attachable serial interface is consistent with the require ments of the pc platform of today and tomorrow. the sonix usb microcontrollers are optimized for human-interface computer peripherals such as a mouse, keyboard, joystick, and game pad. usb specification compliance ? conforms to usb specifications, version 2.0. ? supports 1 full-speed usb device address. ? supports 1 control endpoint, 2 interrupt endpoints and 2 interrupt/bulk endpoints. ? integrated usb transceiver. ? 5v to 3.3v regulator output for d+ 1.5k ohm internal resistor pull up. 9.2 usb machine the usb machine allows the microcontroller to communica te with the usb host. the hardware handles the following usb bus activity independently of the microcontroller. the usb machine will do: ? translate the encoded received data and fo rmat the data to be transmitted on the bus. ? crc checking and generation by hardware. if crc is not corr ect, hardware will not send any response to usb host. ? send and update the data toggle bit (dat a1/0) automatically by hardware. ? send appropriate ack/nak/stall handshakes. ? setup, in, or out token type identification. set t he appropriate bit once a valid token is received. ? place valid received data in the appropriate endpoint fifos. ? bit stuffing/unstuffing. ? address checking. ignore the transactions not addressed to the device. ? endpoint checking. check the endpoint?s request from usb host, and set the appropriate bit of registers. firmware is required to handle the rest of the following tasks: ? coordinate enumeration by dec oding usb device requests. ? fill and empty the fifos. ? suspend/resume coordination. ? remote wake up function. ? determine the right interrupt request of usb communication.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 105 version 1.1 9.3 usb interrupt the usb function will accept the usb host command and generate the relative interrupts, and the program counter will go to 0x08 vector. firmware is required to check the usb st atus bit to realize what r equest comes from the usb host. the usb function interrupt is generated when: ? the endpoint 0 is set to accept a setup token. ? the device receives an ack handshake after a su ccessful read transaction (in) from the host. ? if the endpoint is in ack out modes, an in terrupt is generated when data is received. ? the usb host sends usb suspend request to the device. ? usb bus reset event occurs. ? the usb endpoints interrupt after a usb transaction complete is on the bus. ? the sof packet received if the sof interrupt enable. ? the nak handshaking when the nak interrupt enable. the following examples show how to avoid the error of reading or writing the endpoint fifos and to do the right usb request routine according to the flag. 9.4 usb enumeration a typical usb enumeration sequence is shown below. 1. the host computer sends a setup packet followed by a data packet to usb address 0 requesting the device descriptor. 2. firmware decodes the request and retrieves its de vice descriptor from the program memory tables. 3. the host computer performs a control read sequence and firmware responds by sending the device descriptor over the usb bus, via the on-chip fifo. 4. after receiving the descriptor, the host sends a setup packet followed by a data packet to address 0 assigning a new usb address to the device. 5. firmware stores the new address in its usb device address register after t he no-data control sequence completes. 6. the host sends a request for the devi ce descriptor using the new usb address. 7. firmware decodes the request and retrieves the device descriptor from program memory tables. 8. the host performs a control read sequence and firmware responds by sending its device descriptor over the usb bus. 9. the host generates control reads from the device to request the configuration and report descriptors. 10. once the device receives a set configurat ion request, its functions may now be used. 11. firmware should take appropriate action for endpoint 0~3 transactions, which may occur from this point.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 106 version 1.1 9.5 usb registers 9.5.1 usb device address register the usb device address register (uda) contains a 7-bit usb device address and one bit to enable the usb function. this register is cleared during a reset, setting the usb device address to zero and disable the usb function. 091h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 uda ude uda6 uda5 uda4 uda3 uda2 uda1 uda0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 ude: device function enable. this bit must be enabled by firmware to enable the usb device function. 0 = disable usb device function. 1 = enable usb device function. bit [6:0] uda [6:0]: these bits must be set by firmware during the usb enumeration process (i.e., setaddress) to the non-zero address assigned by the usb host. 9.5.2 usb status register the usb status register indicates the status of usb. 092h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ustatus crcerr pkterr sof bus_rs t suspend ep0setup ep0in ep0out read/write r/w r/w r/w r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 crcerr: usb data crc check error. 0 = non-usb data crc check error, cleared by firmware. 1 = set to 1 by hardware when usb data crc check error occur. bit 6 pkterr: usb packet error. 0 = non-usb packet erro r, cleared by firmware. 1 = set to 1 by hardware when usb packet error occur. bit 5 sof: indicate the usb sie?s sof packet is received 0 = non usb sie?s sof packet received. 1 = if sof_int_en = 1 then this bit will be set to 1 by hardware when the sof packet is received. otherwise the bit will always be 0. bit 4 bus_rst: usb bus reset. 0 = non-usb bus reset. 1 = set to 1 by hardware when usb bus reset request.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 107 version 1.1 bit 3 suspend: indicate usb suspend status. 0 = non-suspend status. when mcu wakeup from sleep mode by usb resume wakeup request, the bit will changes from 1 to 0 automatically. 1 = set to 1 by hardware when usb suspend request. bit 2 ep0setup: endpoint 0 setup token received. 0 = endpoint 0 has no setup token received. 1 = a valid setup packet has been received. the bit is set to 1 after the last received packet in an setup transaction. while the bit is set to 1, the host can not write any data in to ep0 fifo. this prevents sie from overwriting an incoming setup transaction befor e firmware has a chance to read the setup data. bit 1 ep0in: endpoint 0 in token received. 0 = endpoint 0 has no in token received. 1 = a valid in packet has been received. the bit is set to 1 after the last received packet in an in transaction. bit 0 ep0out: endpoint 0 out token received. 0 = endpoint 0 has no out token received. 1 = a valid out packet has been received. the bit is se t to 1 after the last received packet in an out transaction. 9.5.3 usb data count register the usb ep0 out token data byte counter. 093h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep0out_cnt uep0oc4 uep0 oc3 uep0oc2 u ep0oc1 uep0oc0 read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 bit [4:0] uep0c [4:0]: usb endpoint 0 out token data counter. 9.5.4 usb enable control register the register control the regulator output 3.3 volts enable, sof packet receive interrupt, nak handshaking interrupt and d+ internal 1.5k ohm pull up. 094h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 usb_int_en reg_en dp _up_en sof_int_en ep4nak _int_en ep3nak _int_en ep2nak _int_en ep1nak _int_en read/write r/w r/w r/ w r/w r/w r/w r/w after reset 1 0 0 0 0 0 0 bit 7 reg_en: 3.3volts regulator control bit. 0 = disable regulator output 3.3volts.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 108 version 1.1 1 = enable regulator output 3.3volts. bit 6 dp_up_en: d+ internal 1.5k ohm pull up resistor control bit. 0 = disable d+ pull up 1.5k ohm to 3.3volts. 1 = enable d+ pull up 1.5k ohm to 3.3volts. bit 5 sof_int_en: usb sie?s sof packet receive interrupt enable. 0 = disable usb sie?s sof interrupt request. 1 = enable usb sie?s sof interrupt request. bit [3:0] epnnak_int_en [3:0]: ep1~ep4 nak transaction interrupts enable control bits . n = 1, 2, 3, 4. 0 = disable nak transaction interrupt request. 1 = enable nak transaction interrupt request. 9.5.5 usb endpoint?s ack handshaking flag register the status of endpoint?s ack transaction. 095h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep_ack ep4_ack ep3_ack ep2_ack ep1_ack read/write r/w r/w r/w r/w after reset 0 0 0 0 bit [3:0] epn_ack [3:0]: ep1~ep4 ack transaction . n= 1, 2, 3, 4 . the bit is set whenever the endpoint that completes with an ack received. 0 = the endpoint (interrupt pipe) doesn?t complete with an ack. 1 = the endpoint (interrupt pipe) complete with an ack. 9.5.6 usb endpoint?s nak handshaking flag register the status of endpoint?s nak transaction. 096h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep_nak ep4_nak ep3_nak ep2_nak ep1_nak read/write r/w r/w r/w r/w after reset 0 0 0 0 bit [3:0] epn_nak [3:0]: ep1~ep4 nak transaction . n = 1, 2, 3, 4 . the bit is set whenever the endpoint that completes with an nak received. 0 = the epnnak_int_en = 0 or the endpoint (inte rrupt pipe) doesn?t complete with an nak. 1 = the epnnak_int_en = 1 and the endpoint (interrupt pipe) complete with an nak.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 109 version 1.1 9.5.7 usb endpoint 0 enable register an endpoint 0 (ep0) is used to initialize and control the usb dev ice. ep0 is bi-directional (control pipe), as the device, can both receive and transmit data, whic h provides to access the device configuration information and allows generic usb status and control accesses. 097h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue0r - ue0m1 ue0m0 - ue 0c3 ue0c2 ue0c1 ue0c0 read/write - r/w r/ w - r/w r/w r/w r/w after reset - 0 0 - 0 0 0 0 bit [6:5] ue0m [1:0]: the endpoint 0 modes determine how the sie responds to usb traffic that the host sends to the endpoint 0. for example, if the endpoi nt 0?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 0.the bit 5 ue0m0 will auto reset to zero when the ack transaction complete. usb endpoint 0?s mode table ue0m1 ue0m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall bit [3:0] ue0c [3:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmitted to the host from the endpoint 0 fifo. 9.5.8 usb endpoint 1 enable register the communication with the usb host using endpoint 1, endpoint 1?s fifo is implemented as w bytes of dedicated ram. the endponit1 is an interrupt endpoint. 098h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue1r ue1e ue1m1 ue1m0 read/write r/w r/w r/w after reset 0 0 0 bit 7 ue1e: usb endpoint 1 function enable bit. 0 = disable usb endpoint 1 function. 1 = enable usb endpoint 1 function. bit [6:5] ue1m [1:0]: the endpoint 1 modes determine how the sie responds to usb traffic that the host sends to the endpoint 1. for example, if the endpoi nt 1?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 1.the bit 5 ue1m0 will auto reset to zero when the ack transaction complete.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 110 version 1.1 usb endpoint 1?s mode table ue1m1 ue1m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall 099h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue1r_c ue1c5 ue1c4 ue1c3 ue1c ue1c1 ue1c0 read/write r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 bit [5:0] ue1c [5:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmitted to the host from the endpoint 1 fifo. 9.5.9 usb endpoint 2 enable register the communication with the usb host using endpoint 2, endpoint 2?s fifo is implemented as x bytes of dedicated ram. the endpoint 2 is an interrupt endpoint. 09ah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue2r ue2e ue2m1 ue2m0 read/write r/w r/w r/w after reset 0 0 0 bit 7 ue2e: usb endpoint 2 function enable bit. 0 = disable usb endpoint 2 function. 1 = enable usb endpoint 2 function. bit [6:5] ue2m [1:0]: the endpoint 2 modes determine how the sie responds to usb traffic that the host sends to the endpoint 2. for example, if the endpoi nt 2?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 2. the bit 5 ue2m0 will auto reset to zero when the ack transaction complete. usb endpoint 2?s mode table ue2m1 ue2m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 111 version 1.1 09bh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue2r_c ue2c5 ue2c4 ue2c3 ue2c ue2c1 ue2c0 read/write r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 bit [5:0] ue2c [5:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmitted to the host from the endpoint 2 fifo. 9.5.10 usb endpoint 3 enable register the communication with the usb host using endpoint 3, endpoint 3?s fifo is implemented as y bytes of dedicated ram. the endpoint 3 is an interrupt and bulk endpoint. 09ch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue3r ue3e ue3m1 ue3m0 read/write r/w r/w r/w after reset 0 0 0 bit 7 ue3e: usb endpoint 3 function enable bit. 0 = disable usb endpoint 3 function. 1 = enable usb endpoint 3 function. bit [6:5] ue3m [1:0]: the endpoint 3 modes determine how the sie responds to usb traffic that the host sends to the endpoint 3. for example, if the endpoi nt 3?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 3. the bit 5 ue3m0 will auto reset to zero when the ack transaction complete. usb endpoint 3?s mode table ue3m1 ue3m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall 09dh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue3r_c ue3c5 ue3c4 ue3c3 ue3c ue3c1 ue3c0 read/write r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 bit [5:0] ue3c [5:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmitted to the host from the endpoint 3 fifo.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 112 version 1.1 9.5.11 usb endpoint 4 enable register the communication with the usb host using endpoint 4, endpoi nt 4?s fifo is implemented as z bytes of dedicated ram. the endpoint 4 is an interrupt and bulk endpoint. 09eh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue4r ue4e ue4m1 ue4m0 read/write r/w r/w r/w after reset 0 0 0 bit 7 ue4e: usb endpoint 4 function enable bit. 0 = disable usb endpoint 4 function. 1 = enable usb endpoint 4 function. bit [6:5] ue4m [1:0]: the endpoint 4 modes determine how the sie responds to usb traffic that the host sends to the endpoint 4. for example, if the endpoi nt 4?s mode bit is set to 00 that is nak in/out mode as shown in table, the usb sie will send nak handshakes in response to any in/out token set to the endpoint 4. the bit 5 ue4m0 will auto reset to zero when the ack transaction complete. usb endpoint 4?s mode table ue4m1 ue4m0 in/out token handshake 0 0 nak 0 1 ack 1 0 stall 1 1 stall 09fh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ue4r_c ue4c5 ue4c4 ue4c3 ue4c ue4c1 ue4c0 read/write r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 bit [5:0] ue4c [5:0]: indicate the number of data bytes in a transac tion: for in transactions, firmware loads the count with the number of bytes to be transmitted to the host from the endpoint 4 fifo. 9.5.12 usb endpoint fifo address setting register 0a0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep2fifo_a ddr ep2fifo7 ep2fifo6 ep2fifo5 ep2fifo4 ep2fifo3 ep2fifo2 ep2fifo1 ep2fifo0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] ep2fifo_addr [7:0]: ep2 fifo start address.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 113 version 1.1 0a1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep3fifo_a ddr ep3fifo7 ep3fifo6 ep3fifo5 ep3fifo4 ep3fifo3 ep3fifo2 ep3fifo1 ep3fifo0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] ep3fifo_addr [7:0]: ep3 fifo start address. 0a2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 ep4fifo_a ddr ep4fifo7 ep4fifo6 ep4fifo5 ep4fifo4 ep4fifo3 ep4fifo2 ep4fifo1 ep4fifo0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] ep4fifo_addr [7:0]: ep4 fifo start address. 9.5.13 usb data pointer register usb fifo address pointer. use the point to set the fifo address for reading data from usb fifo and writing data to usb fifo. 0a3h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udp0 udp07 udp06 udp05 udp04 udp03 udp02 udp01 udp00 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 usb data pointer: access t he usb data by the data pointer. 9.5.14 usb data read/write register 0a5h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udr0_r udr0_r7 udr0_r6 udr0_r5 udr0_r4 udr0_r3 udr0_r2 udr0_r1 udr0_r0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 udr0_r: read the data from usb fifo which udp0 register point to. 0a6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 udr0_w udr0_w7 udr0_w6 udr0_w5 udr0_w4 udr0_w3 udr0_w2 udr0_w1 udr0_w0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 udr0_w: write the data to usb fifo which udp0 register point to. 9.5.15 upid register forcing bits allow firmware to directly drive the d+ and d? pins. 0a7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 upid - - - - ubde ddp ddn read/write - - - - r/w r/w r/w after reset - - - - 0 0 0
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 114 version 1.1 bit 2 ubde: enable to direct drive usb bus. 0 = disable. 1 = enable. bit 1 ddp: drive d+ on the usb bus. 0 = drive d+ low. 1 = drive d+ high. bit 0 ddn: drive d- on the usb bus. 0 = drive d- low. 1 = drive d- high. 9.5.16 endpoint toggle bit control register . 0ach bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 utoggle - - - - ep4 _data01 ep3 _data01 ep2 _data01 ep1 _data01 read/write - - - - r/w r/w r/w r/w after reset - - - - 1 1 1 1 bit [3:0] endpoint 1~4?s data0/1 toggle bit control. 0 = clear the endpoint 1~4?s toggle bit to data0 1 = hardware set toggle bit automatically.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller 10 universal asynchronous receiver/transmitter (uart) 10.1 overview the uart interface is an universal asynchronous receiver/tr ansmitter method. the serial interface is applied to low speed data transfer and communicate with low speed perip heral devices. the uart transceiver of sonix 8-bit mcu allows rs232 standard and supports one and two bytes data l ength. the transfer format has start bit, 8/16-bit data, parity bit and stop bit. programmable baud rate supports different speed peripheral devices. uart i/o pins support push-pull and open-drain structur es controlled by register. the uart features include the following: z full-duplex, 2-wire asynchronous data transfer. z programmable baud rate. z 8-bit and 16-bit data length. z odd and even parity bit. z end-of-transfer interrupt. 10.2 uart operation the uart rx and tx pins are shared with gpio. when uart enables (urxen=1, utxen=1), the uart shared pins transfers to uart purpose and disabl e gpio function automatically. when uart disables, the uart pins returns to gpio last status. the uart data buffer length supports 1-byte and 2-byte. after uart rx operation finished, the utrxirq sets as ?1?. after uart tx operation finished, t he uttxirq sets as ?1?. the uart irq bits are cleared by program. if the utrxien or uttxien set to enable, the utrxirq and uttxirq triggers the interrupt request and program counter jumps to interrupt vector to execute interrupt service routine. uart interface circuit diagram sonix technology co., ltd page 115 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller the uart transfer format includes ?bus id le status?, ?start bit?, ?8-bit data?, ?parity bit? and ?stop bit? as following. uart transfer format with parity bit uart transfer format without parity bit bus idle status the bus idle status is the bus non-operating status. the uart receiver bus idle status of mcu is floating status and tied high by the transmitter device terminal. the uart transmitte r bus idle status of mcu is high status. the uart bus will be set when urxen and utxen are enabled. start bit uart is a asynchronous type of communication and need a attenti on bit to offer receiver the transfer starting. the start bit is a simple format which is high to low edge change an d the duration is one bit period. the start bit is easily recognized by the receiver. 8-bit data the data format is 8-bit length, and lsb tr ansfers first following start bit. the one bit data duration is the unit of uart baud rate controlled by register. parity bit the parity bit purpose is to detect data error condition. it is an extra bit following the data stream. the parity bit includes odd and even check met hods controlled by urxps/utxps bi ts. after receiving data and parity bit, the parity check executes automatically. the urxpc bit indicates the parity check result. the parity bit function is controlled by urxpen/utxpen bits. if the parity bit function is disabled, t he uart transfer contents re move the parity bit and the stop bit follows the data stream directly. stop bit the stop bit is like start bit using a simple format to indicate the end of uart transfer. the stop bit format is low to high edge change and the duration is one bit period. sonix technology co., ltd page 116 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller the uart communication supports 2-byte data length. t he function is for continuous data streams and immediate data request. the 2-byte data format is a continuously byte data form. the gap between the 2-byte data is unit baud rate. the first byte data stores in urrxd1 (receiver) an d urtxd1 (transmitter). the second byte data stores in urrxd2 (receiver) and urtxd2 (transmitter).t he 2-byte data format is as following. 2-byte transfer format with parity bit 2-byte transfer format without parity bit the uart supports interrupt function. utrxien/uttxie n are uart transfer interrupt function control bit. utrxien=0, disable uart receiver in terrupt function. uttxien=0, disable uart transmitter interrupt function. utrxien=1, enable uart receiver interrupt function. uttx ien=1, enable uart transmitter interrupt function. when uart interrupt function enable, the program counter points to interrupt vector (org 8) to do uart interrupt service routine after uart operating. utrxirq and uttxirq are uart interrupt request flags, and also to be the uart operating status indicator when utrxien=0 or uttxien=0, but cleared by program. when uart operation finished, the utrxirq/uttxirq would be set to ?1?. note: the first step of uart operation is to setup the uart pins? mode. enable urxen/utxen to control uart pins? mode. sonix technology co., ltd page 117 version 1.1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 118 version 1.1 10.3 uart transmitter control register urtx initial value = 0xx0000x 0a9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urtx uclks utxen utxpen utxps utxm read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 bit 7 uclks: uart clock source select bit. 0 = uart clock source is 16mhz. 1 = uart clock source is 24mh. bit 4 utxen: uart tx control bit. 0 = disable uart tx. utx pin keeps and returns to gpio function. 1 = enable uart tx. utx pin transmits uart data. bit 3 utxpen: uart tx parity bit check function control bit. 0 = disable uart tx parity bit check function. the data stream doesn?t include parity bit. 1 = enable uart tx parity bit check function. the data stream includes parity bit. bit 2 utxps: uart tx parity bit format control bit. 0 = uart tx parity bit format is even parity. 1= uart tx parity bit format is odd parity. bit 1 utxm: uart tx data buffer length control bit. 0 = 1-byte. 1 = 2-byte.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 119 version 1.1 10.4 uart receiver control register urrx initial value = 0000000x 0aah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urrx urxen urxs1 urxs0 urxpen urxps urxpc urxm read/write r/w r/w r/ w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 bit 7 urxen: uart rx control bit. 0 = disable uart rx. urx pin keeps and returns to gpio function. 1 = enable uart rx. urx pin receives uart data. bit[6:5] urxs1, urxs0: uart rx status indicator. 00 = no data received. 01 = data received, but parity checking error occurrence. 10, 11 = data received successfully. bit 4 urxpen: uart rx parity bit check function control bit. 0 = disable uart rx parity bit check function. the data stream doesn?t include parity bit. 1 = enable uart rx parity bit check function. the data stream includes parity bit. bit 3 urxps: uart rx parity bit format control bit. 0 = uart rx parity bit format is even parity. 1= uart rx parity bit format is odd parity. bit 2 urxpc: uart rx parity bit checking status bit. 0 = uart rx parity bit checking is error. 1 = uart rx parity bit checking is correct. bit 1 urxm: uart rx data buffer length control bit. 0 = 1-byte. 1 = 2-byte.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 120 version 1.1 10.5 uart baud rate control register urbrc initial value =11010101 0abh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urbrc udiv4 udiv3 udiv2 udiv1 udiv0 upcs2 upcs1 upcs0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 1 1 0 1 0 1 0 1 bit[7:3] udiv[4:0]: uart baud rate divider. bit[2:0] upcs[2:0]: uart baud rate pre-scalar. the uart baud rate clock source is fhosc and divided by pre-scalar and divider. the equation is as following. uart baud rate = (fhosc / 2 prescalar / (divider+1)) / 16 divider 0 uart clock source = 16mhz (uclks = 0) uart clock source = 24mhz (uclks = 1) baud rate upcs[2:0] udiv[4:0] upcs[2:0] udiv[4:0] 1200 101 11010 - - 2400 100 11010 - - 4800 011 11010 - - 9600 010 11010 - - 19200 001 11001 - - 38400 000 11001 - - 51200 000 10011 - - 57600 000 10000 - - 102400 000 01001 - - 115200 - - 000 01100
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 121 version 1.1 10.6 uart data buffer urtxd1 initial value = 00000000 0ach bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urtxd1 utxd17 utxd16 utxd15 utxd14 utxd13 utxd12 utxd11 utxd10 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit[7:0] urtxd1: uart transmitted data buffer byte 1. urtxd2 initial value = 00000000 0adh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urtxd2 utxd27 utxd26 utxd25 utxd24 utxd23 utxd22 utxd21 utxd20 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit[7:0] urtxd2: uart transmitted data buffer byte 2. urrxd1 initial value = 00000000 0aeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urrxd1 read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 bit[7:0] urrxd1: uart received data buffer byte 1. urrxd2 initial value = 00000000 0afh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 urrxd2 read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 bit[7:0] urrxd2: uart received data buffer byte 2. uart data mode urtxd2 urtxd1 urrxd2 urrxd1 1-byte 0x00 1-byte data 0x00 1-byte data 2-byte high-byte data low-byte data high-byte data low-byte data
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 122 version 1.1 11 serial input/output transceiver 11.1 overview the sio (serial input/output) transceiver allows high-s peed synchronous data transfe r between the SN8F2280 series mcu and peripheral devices or between several SN8F2280 devices. these peripheral devices may be serial eeproms, shift registers, display drivers, etc. the SN8F2280 sio featur es include the following: z full-duplex, 3-wire synchronous data transfer z tx/rx or tx only mode z master (sck is clock output) or sl ave (sck is clock input) operation z msb/lsb first data transfer z sdo (p2.1) is programmable open-drain output pin for multiple salve devices application z two programmable bit rates (only in master mode) z end-of-transfer interrupt the siom register can control sio operating function, such as: transmit/receive, clock rate, transfer edge and starting this circuit. this sio circuit will tran smit or receive 8-bit data automatically by setting senb and start bits in siom register. the siob is an 8-bit buffer, which is design ed to store transfer data. sioc and sior are designed to generate sio?s clock source with auto-reload function. the 3-bit i/o counter can monitor the operation of sio and announce an interrupt request after transmitting/receiving 8- bit data. after transferring 8-bit data, this circuit will be disabled automatically and re-transfer data by programming siom register. sio interface circuit diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 123 version 1.1 the system is single-buffered in the transmit direction and double-buffered in t he receive direction. this means that bytes to be transmitted cannot be written to the siob data register before the entire shift cycle is completed. when receiving data, however, a received byte must be read from the siob data register before the next byte has been completely shifted in. otherwise, the first byte is lo st. following figure shows a typical sio transfer between two SN8F2280 micro-controllers. master mcu sends sck for initial the data transfer. both master and slave mcu must work in the same clock edge direction, and then both cont rollers would send and receive data at the same time. shift register (siob) 2nd receive buffer (address = siob) internal bus read siob write siob sio master (sckmd = 0) so si sck shift register (siob) 2nd receive buffer (address = siob) internal bus read siob write siob sio slave (sckmd = 1) si so sck sio data transfer diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 124 version 1.1 the sio data transfer timing as following figure: m l s b c p o l c p h a sck idle status diagrams 0 0 1 low bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 0 1 1 high bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 0 0 0 low 0 1 0 high 1 0 1 low bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 1 1 1 high bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 1 0 0 low 1 1 0 high sio data transfer timing
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 125 version 1.1 11.2 siom mode register 0b0h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siom senb start srate1 srate0 mlsb sckmd cpol cpha read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 senb: sio function control bit. 0 = disable (p2.0~p2.2 is general purpose i/o port). 1 = enable (p2.0~p2.2 is sio pins). bit 6 start: sio progress control bit. 0 = end of transfer. 1 = progressing. bit [5:4] srate1:0: sio?s transfer rate select bit. these 2-bits are workless when sckmd=1. 00 = fcpu/2. 01 = fcpu/64 10 = fcpu/32 11 = fcpu/16. bit 3 mlsb: msb/lsb transfer first. 0 = msb transmit first. 1 = lsb transmit first. bit 2 sckmd: sio?s clock mode select bit. 0 = internal. (master mode) 1 = external. (slave mode) bit 1 cpol: sio?s transfer clock edge select bit. 0 = sck idle status is low status 1 = sck idle status is high status bit 0 cpha: the clock phase bit controls the phase of the clock on which data is sampled. 0 = data receive at the fisrt clock phase. 1 = data receive at t he second clock phase. ? note: 1. if sckmd=1 for external clock, the sio is in slave mode. if sckmd=0 for internal clock, the sio is in master mode. 2. don?t set senb and start bits in the same time. that makes the sio function error. because sio function is shared with port2 for p2.0 as sck, p2.1 as sdo and p2.2 as sdi. the following table shown the port2[2:0] i/o mode be havior and setting when sio function enable and disable. senb=1 (sio function enable) (sckmd=1) sio source = external clock p2.0 will change to input mode automatically, no matter what p2m setting p2.0/sck (sckmd=0) sio source = internal clock p2.0 will change to output mode automatically, no matter what p2m setting p2.1/sdo sio = transmitter/receiver p2.1 will cha nge to output mode automatically, no matter what p2m setting p2.2/sdi p2.2 must be set as input mode in p2m ,or the sio function will be abnormal senb=0 (sio function disable) p2.0/p2.1/p2.2 port2[2:0] i/o mode are fully c ontrolled by p2m when sio function is disable
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 126 version 1.1 11.3 siob data buffer 0b2h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 siob siob7 siob6 siob5 siob4 siob3 siob2 siob1 siob0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 siob is the sio data buffer register. it stores serial i/o transmit and receive data. 11.4 sior register description 0b1h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sior sior7 sior6 sior5 sior4 sior3 sior2 sior1 sior0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 the sior is designed for the sio counter to reload the count ed value when end of counting. it is like a post-scaler of sio clock source and let sio has more flexible to setti ng sck range. users can set the sior value to setup sio transfer time. to setup sior value equation to desire transfer time is as following. sck frequency = sio rate / (256 - sior); sior = 256 - ( 1 / ( sck frequency ) * sio rate ) example: setup the sio clock to be 2mhz. fosc = 12mhz. sio?s rate = fcpu/2. fcpu = fosc/1 = 12mhz. sior = 256 ? (1/(2mhz) * 12mhz/2) = 256 ? 3 = 253 = 0xfd
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 127 version 1.1 example: master, duplex transfer and transmit data on rising edge mov a,txdata ; load transmitted data into siob register. b0mov siob,a mov a,#0feh ; set sio clock b0mov sior,a mov a,#10000000b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a example: slave, duplex transfer and transmit data on rising edge mov a,txdata ; load transfer data into siob register. b0mov siob,a mov a,# 10000100b ; setup siom and enable sio function. b0mov siom,a b0bset fstart ; start trans fer and receiving sio data. chk_end: b0bts0 fstart ; wait the end of sio operation. jmp chk_end b0mov a,siob ; save siob data into rxdata buffer. mov rxdata,a
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 128 version 1.1 12 8 channel analog to digital converter 12.1 overview the analog to digital converter (adc) is sar structure with 8-input sources and up to 4096-step resolution to transfer analog signal into 12-bits digital data. use chs[2:0] bits to select analog signal input pin (ain pin), and gchs bit enables global adc channel, the analog signal inputs to t he sar adc. the adc resolution can be selected 8-bit and 12-bit resolutions through adlen bit. the adc converting rate can be selected by adcks[1:0] bits to decide adc converting time. the adc also builds in p4con register to set pure analog input pin. it is necessary to set p4 as input mode with pull-up resistor by program. after setup adenb and ads bits, the adc starts to convert analog signal to digital data. when the conversion is complete, the adc circuit will set eoc and adcirq bits to ?1? and the digital data outputs in adb and adr registers. if the a dcien = 1, the adc interrupt request oc curs and executes interrupt service routine when adcirq = 1 after adc converting. ? note: 1. set adc input pin i/o direction as input mode without pull-up resistor. 2. disable adc (set adenb = ?0?) before enter power down (sleep) mode to save power consumption. 3. set related bit of p4con register to avoid extra power consumption in power down mode. 4. delay 100us after enable adc (set adenb = ?1 ?) to wait adc circuit ready for conversion.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 129 version 1.1 12.2 adm register 0b6h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adm adenb ads eoc gchs chs3 chs2 chs1 chs0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 adenb: adc control bit. 0 = disable. 1 = enable. bit 6 ads: adc start control bit . 0 = adc converting stops. 1 = start to execute adc converting. bit 5 eoc: adc status bit. 0 = adc progressing. 1 = end of converting and reset ads bit. bit 4 gchs: adc global channel select bit. 0 = disable ain channel. 1 = enable ain channel. bit [3:0] chs[3:0]: adc input channel select bit. 0000 = ain0. 0001 = ain1. 0010 = ain2. 0011 = ain3. 0100 = ain4. 0101 = ain5. 0110 = ain6. 0111 = ain7. 1000 = vss. 1001 = vdd. 12.3 adr registers 0b8h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adr adcks2 adcks1 adcks0 adle n adb3 adb2 adb1 adb0 read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 - - - - bit [7:5] adcks [2:0]: adc?s clock source select bit. adcks2 adcks1 adcks0 adc clock source 0 0 0 fcpu/16 0 0 1 fcpu/8 0 1 0 fcpu/1 0 1 1 fcpu/2 1 0 0 fcpu/64 1 0 1 fcpu/32 1 1 0 fcpu/4 1 1 1 reserved
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 130 version 1.1 bit 4 adlen: adc?s resolution select bits. 0 = 8-bit. 1 = 12-bit. bit [3:0] adb [3:0]: 12-bit low-nibble adc data buffer. 12.4 adb registers 0b7h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adb adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 read/write r r r r r r r r after reset - - - - - - - - bit[7:0] adb[7:0]: 8-bit adc data buffer and the high-b yte data buffer of 12-bit adc. adb is adc data buffer to store adc converter result. the adb register is only 8-bit register including bit 4~bit11 adc data. to combine adb register and th e low-nibble of adr will get full 12-bit adc data buffer. the adc buffer is a read-only register and the initial status is unknown after system reset. ? adb[11:4]: in 8-bit adc mode, the adc data is stored in adb register. ? adb[11:0]: in 12-bit adc mode, the adc data is stored in adb and adr registers. ? note: the initial status of adc data buffer including adb register and adr low-nibble after the system reset is unknown. the ain?s input voltage v.s. adb?s output data ain n adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 0/4096*vrefh 0 0 0 0 0 0 0 0 0 0 0 0 1/4096*vrefh 0 0 0 0 0 0 0 0 0 0 0 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4094/4096*vrefh 1 1 1 1 1 1 1 1 1 1 1 0 4095/4096*vrefh 1 1 1 1 1 1 1 1 1 1 1 1 for different applications, users maybe need more than 8-bit resolution but less than 12-bit. to process the adb and adr data can make the job well. first, the ad resolution must be set 12-bit mode and then to execute adc converter routine. then delete the lsb of adc data and get the new resolution result. the table is as following. adb adr adc resolution adb11 adb10 adb9 adb8 adb7 adb6 adb5 adb4 adb3 adb2 adb1 adb0 8-bit o o o o o o o o x x x x 9-bit o o o o o o o o o x x x 10-bit o o o o o o o o o o x x 11-bit o o o o o o o o o o o x 12-bit o o o o o o o o o o o o o = selected, x = delete
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 131 version 1.1 12.5 p4con registers the port 4 is shared with adc input function. only one pi n of port 4 can be configured as adc input in the same time by adm register. the other pins of port 4 are digital i/o pins. connect an analog signal to coms digital input pin, especially, the analog signal level is about 1/2 vdd will ca use extra current leakage. in the power down mode, the above leakage current will be a big problem. unfortunately, if users connect more than one analog input signal to port 4 will encounter above current leakage situation. p4con is port 4 configuration register. write ?1? into p4con [7:0] will configure related port 4 pin as pure anal og input pin to avoid current leakage. 0b9h bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 p4con p4con7 p4con6 p4con5 p4con4 p4con3 p4con2 p4con1 p4con0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 bit[4:0] p4con[7:0]: p4.n configuration control bits. 0 = p4.n can be an analog input (adc input) or digital i/o pins. 1 = p4.n is pure analog input, can?t be a digital i/o pin. ? note: when port 4.n is general i/o port not adc channel, p4con.n must set to ?0? or the port 4.n digital i/o signal would be isolated. 12.6 adc converting time the adc converting time is from ads=1 (start to adc convert) to eoc=1 (end of adc convert). the converting time duration is depend on adc resolution. 12- bit adc?s converting time is 1/(adc clock /4)*16 sec, and the 8-bit adc converting time is 1/(adc clock /4)*12 sec. the adc converting time affects adc performance. if input high rate analog signal, it is necessary to select a high adc converting rate. if the adc converting time is slower than analog signal variation rate, the adc result would be e rror. so to select a correct adc clock rate and adc resolution to decide a right adc converting rate is very important. 12-bit adc conversion time = 1/(adc clock /4)*16 sec 8-bit adc conversion time = 1/(adc clock /4)*12 sec fcpu = 4mhz ( high clock oscillator freque ncy (fosc) is 16mhz and fcpu = fosc/4) adlen adcks1 adcks0 adc clock adc conversion time 0 0 fcpu/16 1/(4mhz/16/4)*12 = 192 us 0 1 fcpu/8 1/(4mhz/8/4)*12 = 96 us 1 0 fcpu 1/(4mhz/4)*12 = 12 us 0 (8-bit) 1 1 fcpu/2 1/(4mhz/2/4)*12 = 24 us 0 0 fcpu/16 1/(4mhz/16/4)*16 = 256 us 0 1 fcpu/8 1/(4mhz/8/4)*16 = 128 us 1 0 fcpu 1/(4mhz/4)*16 = 16 us 1 (12-bit) 1 1 fcpu/2 1/(4mhz/2/4)*16 = 32 us
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 132 version 1.1 12.7 adc contorl notice 12.7.1 adc signal the adc high reference voltage is internal vdd. the adc low reference voltage is ground. the adc input signal voltage range must be from high reference voltage to low reference voltage. 12.7.2 adc program the first step of adc execution is to setup adc configuration. the adc program setup sequence and notices are as following. z step 1: enable adc. adenb is adc control bit to control. ad enb = 1 is to enable adc. adenb = 0 is to disable adc. when adenb is enabled, the system must be del ay 100us to be the adc warm-up time by program, and then set ads to do adc converting. the 100us de lay time is necessary after adenb setting (not ads setting), or the adc converting result would be error. normally, the adenb is set one time when the system under normal run condition, and do the delay time only one time. z step 2: select the adc input pin by chs[2:0], enable p4con? s related bit for the adc input pin, and enable adc global input. when one ain pin is selected to be analog signal i nput pin, it is necessary to setup the pin as input mode and disable the pull-up resistor by program. also to set the p4con, and the digital i/o function including pull-up is isolated. z step 3: start to execute adc conversion by setting ads = 1. z step 4: wait the end of adc converting th rough checking eoc = 1 or adci rq = 1. if enable adc interrupt function, the program executes adc interrupt service when adc interrupt occurrence. ads is cleared when the end of adc converting automatically. eoc bit i ndicates adc processing status immediately and is cleared when ads = 1. users needn?t to clear it by program. ? example : configure ain0 as 12-bit adc input and start adc conversion then enter power down mode. adc0: b0bset fadenb ; enable adc circuit call delay100us ; delay 100us to wait adc circuit ready for conversion mov a, #0feh b0mov p4ur, a ; disable p4.0 pull-up resistor b0bclr fp40m ; set p4.0 as input pin mov a, #01h b0mov p4con, a ; set p4.0 as pure analog input mov a, #60h b0mov adr, a ; to set 12-bit adc and adc clock = fosc. mov a,#90h b0mov adm,a ; to enable adc and set ain0 input b0bset fads ; to start conversion wadc0: b0bts1 feoc ; to skip, if end of converting =1 jmp wadc0 ; else, jump to wadc0 b0mov a,adb ; to get ain0 input data bit11 ~ bit4 b0mov adc_buf_hi, a b0mov a,adr ; to get ain0 input data bit3 ~ bit0 and a, 0fh b0mov adc_buf_low, a power_down . . b0bclr fadenb ; disable adc circuit b0bclr fcpum1 b0bset fcpum0 ; enter sleep mode
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 133 version 1.1 12.8 adc circuit the analog signal is inputted to adc input pin ?ainn/p4.n?. the adc input signal must be through a 0.1uf capacitor ?a?. the 0.1uf capacitor is set between adc input pin and vss pin, and must be on the side of the adc input pin as possible. don?t connect the capacitor?s ground pin to ground plain directly, and must be throug h vss pin. the capacitor can reduce the power noise effectiv e coupled with the analog signal.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 134 version 1.1 13 main series port (msp) 13.1 overview the msp (main serial port) is a serial communication interface for data exchanging from one mcu to one mcu or other hardware peri pherals. these peripheral devic es may be serial eeprom, a/d converters, display device, etc. the msp module can operate in one of two modes: z full master mode z slave mode (with general address call) the msp features include the following: z 2-wire synchronous data transfer / receiver. z master (scl is clock output) or slav e (scl is clock input) operation. z scl, sda are programmable open-drain output pin for multiple salve devices application. z support 400k clock rate @ fcpu=4mips. z end-of-transfer/receiver interrupt. 13.2 msp status register mspstat initial value =x00000x0 0eah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspstat cke d_a p s red_wrt bf read/write r/w r r r r r after reset 0 0 0 0 0 0 bit 6 cke: slave clock edge control bit. in slave mode: receive address or data byte. 0 = latch data on scl rising edge. (default) 1 = latch data on scl falling edge. ? note 1. in slave transmit mode, address received depended on cke settin g . data transfer on scl falling edge. ? note 2. in slave receiver mode, address and data received depended on cke setting. bit 5 d_a: data/address bit. 0 = indicates the last byte rece ived or transmitted was address. 1 = indicates the last byte received or transmitted was data. bit 4 p: stop bit. 0 = stop bit was not detected. 1 = indicates that a stop bit has been detected last. ? note1. it will be cleared when start bit was detected. bit 3 s: start bit. 0 = start bit was not detected. 1 = indicates that a start bit has been detected last. ? note1. it will be cleared when stop bit was detected. bit 2 red_wrt: read/write bit information. this bit holds the r/w bit information following the last addr ess match. this bit is only valid from the address match to
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 135 version 1.1 the next start bit, stop bit, or not ack bit. in slave mode : 0 = write. 1 = read. in master mode : 0 = transmit is not in progress. 1 = transmit is in progress. or this bit with sen, rsen, pen , rcen, or acken will indicate if the msp is in idle mode. bit 0 bf: buffer full status bit. receive : 1 = receive complete, mspbuf is full. 0 = receive not complete, mspbuf is empty. transmit : 1 = data transmit in progress (does not in clude the ack and stop bits), mspbuf is full. 0 = data transmit complete (does not incl ude the ack and stop bits), mspbuf is empty. 13.3 msp mode register 1 mspm1 initial value =000000x0 0ebh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspm1 wcol mspov mspenb ckp slrxckp mspwk mspc read/write r/w r/w r/ w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 bit 7 wcol: write collision detect bit. master mode : 0 = no collision. 1 = a write to the mspbuf register was attempted while the msp conditions were not valid for a transmission to be started. slave mode : 0 = no collision. 1 = the mspbuf register is written while it is still transmitting the previous word. (must be cleared in software) bit 6 mspov: receive overflow indicator bit. 0 = no overflow. 1 = a byte is received while the mspbuf register is still holding the previous byte. mspov is a ?don?t care? in transmit mode. mspov must be cleared in softwar e in either mode. (must be cleared in software) bit 5 mspenb: main serial port communication enable. 0 = disables main serial port and conf igures these pins as i/o port pins. 1 = enables main serial port and configures scl an d sda as the source of the serial port pins. bit 4 ckp: scl clock priority control bit. in msp slave mode : 0 = hold scl keeping low. (ensure data setup time and slave device ready) 1 = release scl clock. (slave transistor mode ckp function always enables, slave receiver ckp function control by slrxckp) in msp master mode : unused. bit 3 slrxckp: slave receiver mode scl clock priority control bit. in msp slave receiver mode :
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 136 version 1.1 0 = disable ckp function. 1 = enable ckp function. in msp master and slave transistor mode : unused. bit 2 mspwk: msp wake-up indication bit. 0 = mcu not wake-up by msp. 1 = mcu wake-up by msp. ? note: clear mspwk before entering power down mode for indication the wake-up source from msp or not. bit 0 mspc: msp mode control register. 0 = msp operated on slave mode, 7-bit address. 1 = msp operated on master mode. 13.4 msp mode register 2 mspm2 initial value =00000000 0ech bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspm2 gcen ackstat ackdt ac ken rcen pen rsen sen read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit 7 gcen: general call enable bit. (in slave mode only) 0 = general call address disabled. 1 = enable interrupt when a general call address (0000h) is received. bit 6 ackstat: acknowledge status bit. (in master mode only) in master transmit mode : 0 = acknowledge was received from slave. 1 = acknowledge was not received from slave. bit 5 ackdt: acknowledge data bit. (in master mode only) in master receive mode : value that will be transmitted when the user initiates an acknowledge sequence at the end of a receive. 0 = acknowledge. 1 = not acknowledge. bit 4 acken: acknowledge sequence enable bit. (in msp master mode only) in master receive mode : 0 = acknowledge sequence idle. 1 = initiate acknowledge sequence on sda and scl pins, and transmit ackdt data bit. automatically cleared by hardware. ? note: if the msp module is not in the idle mode, this bit may not be set (no spooling), and the mspbuf may not be written (or writes to the mspbuf are disabled). bit 3 rcen: receive enable bit. (in master mode only) 0 = receive idle. 1 = enables receive mode for msp. ? note: if the msp module is not in the idle mode, this bit may not be set (no spooling), and the mspbuf may not be written (or writes to the mspbuf are disabled). bit 2 pen: stop condition enable bit. (in master mode only)
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 137 version 1.1 0 = stop condition idle. 1 = initiate stop condition on sda and scl pins. automatically cleared by hardware. ? note: if the msp module is not in the idle mode, this bit may not be set (no spooling), and the mspbuf may not be written (or writes to the mspbuf are disabled). bit 1 rsen: repeated start condition enabled bit. (in master mode only) 0 = repeated start condition idle. 1 = initiate repeated start condition on sda and scl pins. automatically cleared by hardware. ? note: if the msp module is not in the idle mode, this bit may not be set (no spooling), and the mspbuf may not be written (or writes to the mspbuf are disabled). bit 0 sen: start condition enabled bit. (in master mode only) 0 = start condition idle. 1 = initiate start condition on sda and scl pins. automatically cleared by hardware. ? note: if the msp module is not in the idle mode, this bit may not be set (no spooling), and the mspbuf may not be written (or writes to the mspbuf are disabled). 13.4 msp buffer register mspbuf initial value =00000000 0edh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspbuf mspbuf7 mspbuf6 mspbuf5 mspbuf4 mspbuf3 mspbuf2 mspbuf1 mspbuf0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit[7:0] mspbuf: msp buffer. 13.5 msp address register mspadr initial value =00000000 0eeh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mspadr mspadr7 mspadr6 mspadr5 mspadr4 mspadr3 mspadr2 mspadr1 mspadr0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit[7:0] mspadr: msp address.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 138 version 1.1 13.6 slave mode operation when an address is matched or data transfer after and addr ess match is received, the hardware automatically will generate the acknowledge (ack_) si gnal, and load mspbuf (msp buffer regist er) with the received data from mspsr. there are some conditi ons that will cause msp functi on will not reply ack_ signal: z data buffer already full: bf=1 (mspstat bit 0), when another transfer was received. z data overflow: mspov=1 (mspm1 bit 6), when another transfer was received. when bf=1, means mspbuf data is still not read by mcu, so mspsr will not load data into mspbuf, but mspirq and mspov bit will still set to 1. bf bit will be clear automat ically when reading mspbuf register. mspov bit must be clear through by software. 13.6.1 addressing when msp slave function has been enabled, it will wait a start signal occur. following the start signal, 8-bit address will shift into the mspsr regist er. the data of mspsr[7:1] is compar e with mspadr register on the falling edge of eight scl pulse, if the address are the same, the bf and mspov bit are both clear, the following event occur: 1. mspsr register is loaded into m spbuf on the falling edge of eight scl pulse. 2. buffer full bit (bf) is set to 1, on the falling edge of eight scl pulse. 3. an ack_ signal is generated. 4. msp interrupt request mspirq is set on the falling edge of ninth scl pulse. status when data is received bf mspov mspsp? mspbuf reply an ack_ signal set mspirq 0 0 yes yes yes *0 *1 yes no yes 1 0 no no yes 1 1 no no yes data received action table note: bf=0, mspov=1 shows the software is not set properly to clear overflow register. 13.6.2 slave receiving when the r/w bit of address byte =0 a nd address is matche d, the r/w bit of mspstat is cleared. the address will be load into mspbuf. after reply an ack_ signal, msp will receive data every 8 clock. the ckp function enable or disable (default) is controlled by slrxckp bit and data latc h edge -rising edge (default) or falling edge is controlled by cke bit. when overflow occur, no acknowledge signal replied which either bf=1 or mspov=1. msp interrupt is generated in every data transfer . the mspirq bit must be clear by software. following is the slave receiving diagram: slrxckp=0
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 139 version 1.1 slrxckp=1 13.6.3 slave transmission after address match, the following r/w bit is set, mspstat bit 2 r/w will be set. the re ceived address will be load to mspbuf and ack_ will be sent at ninth clock then scl w ill be hold low. transmission data will be load into mspbuf which also load to mspsr register. t he master should monitor scl pin signal. the slave device may hold on the master by keep ckp low. when set. after load mspbuf, se t ckp bit, mspbuf data will shift out on the falling edge on scl signal. this will ensure the sda signal is valid on the scl high duty. an msp interrupt is generated on every byte transmission. the mspirq will be set on the ninth clock of scl. clear mspirq by software. mspstat register can monitor the status of data transmission. in slave transmission mode, an ack_ signal from master-receive r is latched on rising edge of ninth clock of scl. if ack_ = high, transmission is complete . slave device will reset logic and waiting another start signal. if ack_= low, slave must load mspbuf which also mspsr, and set ckp=1 to start data transmission again. msp slave transmission timing diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 140 version 1.1 13.6.4 general call address in msp bus, the first 7-byte is the slave address. only the address match mspadr the slave will response an ack_. the exception is the general call address which can address all slave devices. when this address occur, all devices should response an acknowledge. the general call address is a special addr ess which is reserved as all ?0? of 7- bits address. the general call address function is control by gcen bit. set this bit will enable general call address and clear it will disable. when gcen=1, following a start signal, 8-bit will shift into mspsr and t he address is compared with mspadr and also the general call address which fixed by hardware. if the general call address matche s, the mspsr data is transferred into ms pbuf, the bf flag bit is set, and in the falling edge of the ninth clock (ack_) mspi rq flag set for interrupt request. in the interrupt service routine, reading mspbuf can check if the add ress is the general call addr ess or device specific. general call address timing diagram 13.6.5 slave wake up when mcu enter power down mode, if mspenb bit is still set, mcu can wa ke-up by matched device address. the address of msp bus following star t bit, 8-bits address will shift into mspsr, if address matched, an not acknowledge will response on the nint h clock of scl and mcu will be wake -up, mspwk set and start wake-up procedure but mspirq will not set an d mspsr data will not load to mspubf. after mcu finish wa ke-up procedure, msp will be in idle status and waiting master?s start si gnal. control register bf, mspirq, mspov and mspbuf will be the same status/data before power down. if address not matches, a not acknowledge is still sent on t he ninth clock of scl, but mcu will be not wake-up and still keep in power down mode. msp wake-up timing diagram: address not matched
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 141 version 1.1 msp wake-up timing diagram: address matched ? note: 1. msp function only can work on normal mode, when wake-up from power down mode, mcu must operate in normal mode before master sent start signal. ? note:2. in msp wake-up, if the address not match, mcu will keep in power down mode. ? note 3. clear mspwk before enter power down mode by software for wake-up indication.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 142 version 1.1 13.7 master mode operation master mode of msp operation from a start signal and end by stop signal. the start (s) and stop (p) bit are clear when reset or msp function disabled. in master mode the scl and sda line are controlled by msp hardware. following events will set msp interrupt request (mspirq), if mspien set, interrupt occurs. z start condition. z stop condition. z data byte transmitted or received. z acknowledge transmit. z repeat start. 13.7.1 master mode support master mode enable when mspc and mspen b bit set. once the master mode ena bled, the user had following six options. z send a start signal on scl and sda line. z send a repeat start signal on scl and sda line. z write to mspbuf register for data or address byte transmission. z send a stop signal on scl and sda line. z configuration msp port for receive data. z send an acknowledge at the end of a received byte of data. 13.7.2 msp rate generator (mrg) in msp mode, the msp rate generator?s reload value is loca ted in the lower 7 bit of mspadr register. when mrg is loaded with the register, the mrg count down to 0 and stop until another reload has taken place. in msp mater mode mrg reload from mspadr automatically. if clock arbitration occur for instance (scl pin k eep low by slave device), the mrg will reload when scl pin is detected high. scl clock rate = fcpu/(mspadr)*2 for example, if we want to set 400khz in 4mhz fcpu, the mspadr have to set 0x05h. mspadr=4mhz/400khz*2=5 msp rate generator block diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 143 version 1.1 mrg timing diagram with and without clock arbitration (mspadr=0x03) 13.7.3 msp master mode start condition to generate a start signal, user sets sen bit (mspm2.0) . when sda and scl pin are both sampled high, msp rate generator reload mspadr[6:0], and star ts down counter. when sda and scl are both sampled high and mrg overflow, sda pin is drive low. when scl sampled high, and sda transmitted from high to low is the start signal and will set s bit (mspstat.3). mrg reload again and start do wn counter. sen bit will be clear automatically when mrg overflow, the mrg is suspend leaving sda line held low, and start condition is complete. wcol status flag if user write to mspbuf when start c ondition processing, then wcol is set and the content of mspbuf data is un-changed. (the writer doesn?t occur) start condition timing diagram 13.7.4 msp master mode repeat start condition when msp logic module is idle and rsen set to 1, repeat start progress occurs. rsen set and scl pin is sampled low, mspadr[6:0] data reload to msp ra te generator and start dow n counter. the sda pin is release to high in one msp rate generate counter (t mrg ). when the mrg is overflow, if sda is sampled high. scl will be brought high. when scl is sampled high, mspadr reload to mrg and start down counter. sda and scl must keep high in one t mrg period. in the next t mrg period, sda will be brought low when scl is sa mpled high, then rsen will clear automatically by hardware and mrg will not reload, leaving sda pin hel d low. once detect sda and scl occur start condition, the s bit will be set (mspstat.3). mspirq will not set until mrg overflow. ? note: 1. while any other event is progress, set rsen will take no effect. ? note:2. a bus collision during the repeat start condition occur: sda is sampled low when scl goes from low to high. wcol status flag if user write to mspbuf when repeat start condition pr ocessing, then wcol is set and the content of mspbuf data is un-changed. (the writer doesn?t occur)
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 144 version 1.1 repeat start condition timing diagram 13.7.5 acknowledge sequence timing an acknowledge sequence is enabled when set acken (m spm2.4). scl is pulled low when set acken and the content of the acknowledge data bit is present on sda pin. if user wished to reply an acknowledge, ackdt bit should be cleared. if not, set ackdt bit before starting a acknow ledge sequence. scl pin will be release (brought high) when msp rate generator overflow. msp rate generator start a t mrg period down counter, when scl is sampled high. after this period, scl is pulled low, and acken bit is clear au tomatically by hardware. when next mrg overflow again, msp goes into idle mode. wcol status flag if user write to mspbuf when acknowl edge sequence processing, then wcol bit is set and the content of mspbuf data is un-changed. (the writer doesn?t occur) acknowledge sequence timing diagram 13.7.6 msp master mode stop condition timing at the end of received/transmitted, a stop signal present on sda pin by setting the stop bit register, pen (mspm2.2). at the end of receive/transmit, scl goes low on t he failing edge of ninth clock. master will set sda go low, when set pen bit. when sda is sampled low, msp rate ge nerator is reloaded and start count down to 0. when mrg overflow, scl pin is pull high. after one t mrg period, sda goes high. when sda is sampled high while scl is high, bit p is set. pen bit is clear after next one t mrg period, and mspirq is set. wcol status flag if user write to mspbuf when a stop co ndition is processing, then wcol bit is set and the content of mspbuf data is un-changed. (the writer doesn?t occur)
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 145 version 1.1 sda scl t mrg t mrg falling edge of ninth edge p p bit is set t mrg set pen here sda goes low before the rising edge of scl to set up stop signal scl goes high on next t mrg t mrg pen is clear by hardware and mspirq bit is set stop condition sequence timing diagram 13.7.6 clock arbitration clock arbitration occurs when the master, during any receive, transmit or repeat start, stop condition that scl pin allowed to float high. when scl pin is allowed float high, the msp rate generator (mrg) suspended from counting until the scl pin is actually sampled high. when scl is sampled high, the mrg is reloaded with the content of mspadr[6:0], and start down counter. this ensure that scl high time will always be at least one mrg overflow time in the event that the clock is held low by an external device. clock arbitration sequence timing diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 146 version 1.1 13.7.6 master mode transmission transmission a data byte, 7-bit address or the eight bit data is accomplished by simply wr ite to mspbuf register. this operation will set the buffer full flag bf and allow msp rate generator start counting. after write to mspbuf, each bit of address will be shifted out on the falling ed ge of scl until 7-bit address and r/w bit are complete. on the falling edge of eighth clock, the master will pull low sda fort slave device respond with an acknowledge. on the ninth clock falling edge, sda is sampled to indicate the address alread y accept by slave device. the status of the ack bit is load into ackstat status bit. then mspirq bit is set, the bf bit is clear and the mrg is hold off until another write to the mspbuf occurs, holding scl low and allow sda floating. bf status flag in transmission mode, the bf bit is se t when user writes to mspbuf and is cleared automatically when all 8 bit data are shift out. wcol flag if user write to mspbuf during transmission sequence in progress, the wcol bit is set and the content of mspbuf data will unchanged. ackstat status flag in transmission mode, the ackstat bit is cleared when the slave has sent an acknowledge (ack_=0), and is set when slave does not acknowledge (a ck_=1). a slave send an acknowledge when it has recognized its address (including general call), or when the slave has properly received the data. msp master transmission mode timing diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 147 version 1.1 13.7.7 master mode receiving master receiving mode is enable by set rcen bit. the mrg start counting and when scl cha nge state from low to high, the data is shifted into mspsr. after the falling edge of eighth clock, the receiv e enable bit (rcen) is clear automatically, the contents of msp are load into mspbuf, the bf flag is set, the mspirq flag is set and mrg counter is suspended from counting, holding scl low. the msp is now in idle mode and awaiting the next operation command . when the mspbuf data is read by software, the bf flag is clear automatically. by setting acken bit, user can send an acknowledge bit at the end of receiving. bf status flag in reception mode, the bf bit is set when an address or data by te is loaded into mspbuf from mspsr. it is cleared automatically when mspbuf is read. mspov flag in receive operation, the mspov bit is set when another 8-bit are received into mspsr, and the bf bit is already set from previous reception. wcol flag if user write to mspbuf when a receive is already progress, the wc ol bit is set and the content of mspbuf data will unchanged. msp master receiving mode timing diagram
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 148 version 1.1 14 flash 14.1 overview the SN8F2280 series usb mcu integrated device featur e in-system programmable (isp) flash memory for convenient, upgradeable code storage. the flash me mory may be programmed via the sonix 8 bit mcu programming interface or by application code and usb in terface for maximum flexibility. the SN8F2280 provides security options at the disposal of the designer to prevent unauthorized access to information stored in flash memory. ? the mcu is stalled during flash write (program) and eras e operations, although peripherals (usb, timers, wdt, i/o, pwm, etc.) remain active. ? interrupts will disable by firmware during a flash write or erase operation. ? the flash page containing the code option (rom address 0x2f80 ~ 0x2fff) cannot be erased from application code when the code option?s security enable. ? watch dog timer should be clear before the flash write or erase operation. ? the erase operation sets all the bi ts in the flash page to logic 1. ? hardware will hold system clock and automatically move out data from ram and do programming, after programming finished, hardware will release system cl ock and let mcu execute the next instruction.(recommend add two nop instructions after this active) .
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 149 version 1.1 14.2 flash programming/erase control register 0bah bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 pecmd pecmd7 pecmd6 pecmd5 pecmd4 pecmd3 pecmd2 pecmd1 pecmd0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 bit [7:0] pecmd[7:0]: 0x5a: page program (32 words/page) , 0xc3: page erase (128 words/page) 14.3 programming/erase address register 0bbh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peroml peroml7 peroml6 per oml5 peroml4 peroml3 per oml2 peroml1 peroml0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] peroml[7:0]: define the target starting low byte address [7:0 ] of flash memory (12k x 16) which is going to be programmed or erased. 0bch bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peromh peromh7 peromh6 per omh5 peromh4 peromh3 per omh2 peromh1 peromh0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 bit [7:0] peromh [7:0]: define the target starting high address [15:8] of flash memory (12k x 16) which is going to be programmed or erased. the valid page erase starting addresses are 0x0, 0x80, 0x100, 0x180, 0x 200, 0x280, 0x300, 0x380 ? 0x2f80. the page erase function is used to erase a page of 128 contiguous words in flash rom. the valid page program starting addresses are 0x0, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0 ? 0x2fe0. the page program function is used to program a page of 32 contiguous words in flash rom.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 150 version 1.1 12kx16 flash 0000h reset vector user reset vector jump to user start address 0001h . . 0007h general purpose area 0008h interrupt vector user interrupt vector 0009h user program . . 000fh 0010h 0011h . . . . . general purpose area 2f80h . end of user program 2ffch 2ffdh 2ffeh 2fffh security protect & reserved (code option) flash rom mapping note: 1. if the code option security = 1, the flash rom address = 0x2f80 ~ 0x2fff will not allow to do the ?page erase and page program?.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 151 version 1.1 14.4 programming/erase data register 0bdh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peraml peraml7 peraml6 peraml5 peraml4 peraml3 peraml2 peraml1 peraml0 read/write r/w r/w r/ w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 0beh bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 peramcnt peramcnt4 peramcnt3 peramcnt2 peramcn t1 peramcnt0 - peraml9 peraml8 read/write r/w r/w r/w r/w r/w - - r/w after reset 0 0 0 0 0 - - 0 {peramcnt [1:0], peraml [7:0]} : define the starting ram address [9:0], which stores the data wanted to be programmed. the valid ram addresses are 00h ~ 07fh and 0100h ~ 027fh. peramcnt [7:3] : defines the number of words wanted to be programmed. the maximum peramcnt [7:3] is 01fh, which program 32 words (64 bytes ram) to the flash. the minimum peramcnt [7:3] is 00h, which program only 1 word to the flash. 14.4.1 flash in-system-programming mapping address ram (byte) flash rom (word) bit7 ~ bit0 bit15 ~ bit8 bit7 ~ bit0 x data0 y data1 data0 x+1 data1 y+1 data3 data2 x+2 data2 => y+2 x+3 data3 y+3 ? ? x+n datan y+m datan datan-1
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 152 version 1.1 15 instruction table field mnemonic description c dc z cycle mov a,m a m - - 1 m mov m,a m a - - - 1 o b0mov a,m a m (bank 0) - - 1 v b0mov m,a m (bank 0) a - - - 1 e mov a,i a i - - - 1 b0mov m,i m i, ?m? only supports 0x80~0x87 registers (e.g. pflag,r,y,z?) - - - 1 xch a,m a m - - - 1+n b0xch a,m a m (bank 0) - - - 1+n movc r, a rom [y,z] - - - 2 adc a,m a a + m + c, if occur carry, then c=1, else c=0 1 a adc m,a m a + m + c, if occur carry, then c=1, else c=0 1+n r add a,m a ( a + m, if occur carry, then c=1, else c=0 1 i add m,a m ( a + m, if occur carry, then c=1, else c=0 1+n t b0add m,a m (bank 0) ( m (bank 0) + a, if occur carry, then c=1, else c=0 1+n h add a,i a ( a + i, if occur carry, then c=1, else c=0 1 m sbc a,m a ( a - m - /c, if occur borrow, then c=0, else c=1 1 e sbc m,a m ( a - m - /c, if occur borrow, then c=0, else c=1 1+n t sub a,m a ( a - m, if occur borrow, then c=0, else c=1 1 i sub m,a m ( a - m, if occur borrow, then c=0, else c=1 1+n c sub a,i a a - i, if occur borrow, then c=0, else c=1 1 and a,m a a and m - - 1 l and m,a m a and m - - 1+n o and a,i a a and i - - 1 g or a,m a a or m - - 1 i or m,a m a or m - - 1+n c or a,i a a or i - - 1 xor a,m a a xor m - - 1 xor m,a m a xor m - - 1+n xor a,i a a xor i - - 1 swap m a (b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1 p swapm m m(b3~b0, b7~b4) m(b7~b4, b3~b0) - - - 1+n r rrc m a rrc m - - 1 o rrcm m m rrc m - - 1+n c rlc m a rlc m - - 1 e rlcm m m rlc m - - 1+n s clr m m 0 - - - 1 s bclr m.b m.b 0 - - - 1+n bset m.b m.b 1 - - - 1+n b0bclr m.b m(bank 0).b 0 - - - 1+n b0bset m.b m(bank 0).b 1 - - - 1+n cmprs a,i zf,c a - i, if a = i, then skip next instruction - 1 + s b cmprs a,m zf,c a ? m, if a = m, then skip next instruction - 1 + s r incs m a m + 1, if a = 0, then skip next instruction - - - 1+ s a incms m m m + 1, if m = 0, then skip next instruction - - - 1+n+s n decs m a m - 1, if a = 0, then skip next instruction - - - 1+ s c decms m m m - 1, if m = 0, then skip next instruction - - - 1+n+s h bts0 m.b if m.b = 0, then skip next instruction - - - 1 + s bts1 m.b if m.b = 1, then skip next instruction - - - 1 + s b0bts0 m.b if m(bank 0).b = 0, then skip next instruction - - - 1 + s b0bts1 m.b if m(bank 0).b = 1, then skip next instruction - - - 1 + s jmp d pc15/14 rompages1/0, pc13~pc0 d - - - 2 call d stack pc15~pc0, pc15/14 rompages1/0, pc13~pc0 d - - - 2 m ret pc stack - - - 2 i reti pc stack, and to enable global interrupt - - - 2 s push to push acc and pflag (except nt0, npd bit) into buffers. - - - 1 c pop to pop acc and pflag (except nt0, npd bit) from buffers. 1 nop no operation - - - 1 note: 1. ?m? is system register or ram. if ?m? is system registers then ?n? = 0, otherwise ?n? = 1. 2. if branch condition is true then ?s = 1?, otherwise ?s = 0?.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 153 version 1.1 16 development tool sonix provides ice (in circuit emulation), ide (integrate d development environment), ev-kit and firmware library for usb application development. ice and ev-kit are external hardwa re device and ide is a friendly user interface for firmware development and emulation. 16.1 ice (in circuit emulation) the ice called ?sn8ice2k plus?
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 154 version 1.1 16.2 SN8F2280 ev-kit SN8F2280 ev-kit includes ice interface, gp io interface, usb interface, uart inte rface, sio interface, msp interface, pwm interface, and vreg 3.3v power supply. z ice interface: interface co nnected to sn8ice2k plus. z gpio interface: sn8f2288 package form connector. z usb interface: usb mini-b connector. z uart interface: interface connected to universa l asynchronous receiver/transmitter (uart) connector. z sio interface: interface connected to seri al input/output transceiver (sio) connector. z msp interface: interface connected to main series port (msp) connector. z pwm interface: output the pwm signal to pwm connector. z vreg 3.3v power supply: use sn8p2212?s vr eg to supply 3.3v power for vreg33 pin. the outline of SN8F2280 ev-kit is as following. z con1: ice interface connected to sn8ice2k plus. z j1: jumper to connect between the 5v vdd from sn 8ice2k plus and vdd on sn8f2288 package form socket. z j7: usb mini-b connector. z u11: sn8p2212 to supply 3.3v power for vreg33 pin and usb phy. z jp2: sn8f2288 connector for user?s target board. z jp3: sn8f2288 to supply p0 and p1 i/o level change interrupt function. z j2-j4: uart interface con nected to rs-232 connector. z jp4: sio interface connector, msp interface connec tor, uart interface connector, and pwm interface connector. ? note 1: in the ev-kit, uart and msp are not buil t-in open-drain function, such as p0.5/urx, p0.6/utx, p1.0/scl, p1.1/sda. these are different from ic.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 155 version 1.1 ? note 2: in the ev-kit, port 2, p0.5/urx, p0.6/utx, p1.0 /scl, p1.1/sda, and p5.5 /pwm2 are built-in 1k ohm external pull up resisters. ? note 3: in the ev-kit, port 2 is not schmitt trigger structure. this is different from ic. 16.3 SN8F2280 transition board SN8F2280 transition boards is designated to ic lqfp packa ge. the following shows the transition board outline for sn8f2288. among the board, both c1 and c2 must be welded by 1uf capacitor.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 156 version 1.1 17 electrical characteristic 17.1 absolute maximum rating supply voltage (vdd)????????????????????????????????????????????.?????? - 0.3v ~ 5.5v input in voltage (vin)????????????????????????????????????????????.? vss ? 0.2v ~ vdd + 0.2v operating ambient temperature (topr) sn8f2288f ?????????...???????????..??...????. ??????? 0 c ~ + 70 c storage ambient temperature (tstor) ?????????????????????????.???????????????? ?30 c ~ + 125 c 17.2 electrical characteristic (all of voltages refer to vss, vdd = 5.0v, fosc = 12mhz, ambient temperature is 25 c unless otherwise note.) parameter sym. description min. typ. max. unit vdd1 normal mode except usb transmitter 4.0 5 5.5 v operating voltage vdd2 usb mode 4.25 5 5.25 v ram data retention voltage vdr - 1.5* - v vdd rise rate vpor vdd rise rate to ensure power-on reset 0.05 - - v/ms vil1 p0, p1, p4, p5 input ports vss - 0.2vdd v input low voltage vil2 p2 input ports vss - 0.2 vreg33 v vih1 p0, p1, p4, p5 input ports 0.8vdd - vdd v input high voltage vih2 p2 input ports 0.8 vreg33 - vreg33 v vin1 p0, p1, p4, p5 i/o port?s input voltage range -0.5 - vdd+0.5 v input voltage vin2 p2 i/o port?s input voltage range -0.3 - vreg33 +0.3 v voh1 p0, p1, p4, p5 output ports 0 - vdd v output voltage voh2 p2 output ports 0 - vreg33 v reset pin leakage current ilekg vin = vdd - - 2 ua i/o port pull-up resistor rup1 rup1 p0, p1, p4, p5 ?s vin = vss, vdd = 5v 25 40* 70 k i/o port pull-up resistor rup2 rup2 p2?s vin = vss, vdd = 5v 30 55* 100 k d+ pull-up resistor rd+ vdd = 5v, vreg = 3.3v 1 1.5 1.65 k i/o port input leakage current ilekg pull-up resistor disable, vin = vdd - - 2 ua ioh1 p0, p1, p4, p5 i/o port?s output source current, vop1 = vdd ? 1v 15 20* i/o output source current ioh2 p2 i/o port?s output source current, vop2 = vreg33 ? 1v 1 2* iol1 p0, p1, p4, p5 i/o port?s sink current, vop1 = vss + 0.4v 15* 20 sink current iol2 p2 i/o port?s sink current, vop2 = vss + 0.4v 2* 3 ma intn trigger pulse width tint0 int0 inte rrupt request pulse width 2/fcpu - - cycle page erase (128 words) terase flash rom page erase time - 25* 50 ms page program (32 words) tpg flash rom page program time (program 32 words) - 1* 2 ms vreg33 regulator current ivreg33 vreg33 max regulator output current, vcc > 4.35 volt with 10uf to gnd - - 60 ma vreg33 regulator gnd current ivreg33 _gnl no loading. vreg33 pin output 3.3v ((regulator enable) - 70 100 ua vreg25 regulator gnd current ivreg25 _gnl no loading.vreg25 pin output 2.5v ((regulator enable) - 120 150 ua vreg1 vcc > 4.35v, 0 < temp < 40c, ivreg 60 ma with 10uf to gnd Q 3.0 - 3.6 v vreg33 regulator output voltage vreg2 vcc > 4.35v, 0 < temp < 40c, ivreg 25 ma with 10uf to gnd Q 3.1 - 3.6 v
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 157 version 1.1 idd1 normal mode (no loading, fcpu = fosc/1) vdd= 5v, 12mhz - 10 15 ma idd2 slow mode (internal low rc) vdd= 5v, 12khz - 190 250 ua idd3 sleep mode vdd= 5v - 190 250 ua vdd= 5v, 12mhz - 5 10 ma supply current idd4 green mode (no loading, fcpu = fosc/4 watchdog disable) vdd=5v, ilrc 12khz - 190 250 ua vdet1 low voltage reset level low. 1.6 1.8 2.0 v vdet2 low voltage reset level middle. 2.0 2.4 2.9 v lvd voltage vdet3 low voltage reset level high. 3.0 3.6 4.2 v * these parameters are for design reference, not tested.
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 158 version 1.1 18 flash rom programming pin programming information of SN8F2280 series chip name sn8f2288f/j ez writer / mp writer connector flash ic / jp3 pin assigment numbe r name number pin number pin number pin number pin number pin 1 vdd 7 29 vdd 2 gnd 16 25 vss 3 clk 47 p1.4 4 ce 5 pgm 1 p1.2 6 oe 46 p1.5 7 d1 8 d0 9 d3 10 d2 11 d5 12 d4 13 d7 14 d6 15 vdd 16 - 17 hls 18 rst 19 - 20 alsb/pdb 48 p1.3
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 159 version 1.1 19 package information 19.1 lqfp 48 pin min nor max symbols (mm) a - - 1.6 a1 0.05 - 0.15 a2 1.35 - 1.45 c1 0.09 - 0.16 d 9.00 bsc d1 7.00 bsc e 9.00 bsc e1 7.00 bsc e 0.5 bsc b 0.17 - 0.27 l 0.45 - 0.75 l1 1 ref
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 160 version 1.1 19.2 qfn 48 pin
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 161 version 1.1 20 marking definition 20.1 introduction there are many different types in sonix 8-bit mcu production line. this note listed the produ ction definition of all 8-bit mcu for order or obtain information. 20.2 marking indetification system title sonix 8-bit mcu production rom type p=otp f=flash memory material b = pb-free package g = green package temperature range - = 0 ~ 70 d = -40 ~ 85 shipping package w = wafer h = dice k = sk-dip p = p-dip s = sop x = ssop f = lqfp j = qfn device device part no. sn8x part no. xxx
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 162 version 1.1 20.3 marking example name rom type device package temperature material sn8f2288fg flash memory 2288 lqfp 0 ~70 green package sn8f2288w flash memory 2288 wafer 0 ~70 - sn8f2288h flash memory 2288 dice 0 ~70 - 20.4 datecode system x x x x xxxxx year month 1=january 2=february . . . . 9=september a=october b=november c=december sonix internal use day 1=01 2=02 . . . . 9=09 a=10 b=11 . . . . 03= 2003 04= 2004 05= 2005 06= 2006 . . . .
SN8F2280 series usb 2.0 full-speed 8-bit micro-controller sonix technology co., ltd page 163 version 1.1 sonix reserves the right to make change without further notic e to any products herein to improve reliability, function or design. sonix does not assume any liability arising out of th e application or use of any product or circuit described herein; neither does it convey any license under its patent rights no r the rights of others. sonix products are not designed, intended, or authorized for us as components in systems intended, for surgical implant into the body, or other applications intended to support or sustain life, or for any other applicati on in which the failure of the sonix product could create a situation where personal injury or death may occur. s hould buyer purchase or use sonix products for any such unintended or unauthorized application. buyer shall indemnify and hold sonix and its officers , employees, subsidiaries, affiliates and distributors harmless against all claims, cos t, damages, and expenses, and reasonabl e attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that sonix was negligent regarding the design or manufacture of the part. main office: address: 10f-1, no. 36, taiyuan stree., chupei city, hsinchu, taiwan r.o.c. tel: 886-3-5600 888 fax: 886-3-5600 889 taipei office: address: 15f-2, no. 171, song ted road, taipei, taiwan r.o.c. tel: 886-2-2759 1980 fax: 886-2-2759 8180 hong kong office: unit no.705,level 7 tower 1,grand central plaza 138 shatin rural committee road,shatin,new territories,hong kong. tel: 852-2723-8086 fax: 852-2723-9179 technical support by email: sn8fae@sonix.com.tw


▲Up To Search▲   

 
Price & Availability of SN8F2280

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X